object sends SQL statements to a database. There are three kinds of Statement
Each is specialized to send a particular type of SQL statement:
object is used to execute a simple SQL statement with no parameters.
object is used to execute a pre-compiled SQL statement with or without IN parameters.
object is used to execute a call to a database stored procedure.
You must construct a Statement
object before executing an SQL statement. The Statement
object offers a way to send a SQL statement to the server (and gain access to the result set). Each Statement
object belongs to a Connection
; use the createStatement()
method to ask the Connection
to create the Statement
object defines several methods to execute different types of SQL statements. In the sample application, the executeQuery()
method executes a SELECT
method expects a single argument: the SQL statement that you want to execute. executeQuery()
returns data from the query in a ResultSet
object. If the server encounters an error while executing the SQL statement provided, it throws an SQLException
(and does not return a ResultSet