Statement objects are created by Connection objects
Connection conn = dataSource.getConnection(user, passwd); Statement stmt = conn.createStatement()
The Statement interface defines methods for executing SQL statements.
There is also two subclasses:
- The PreparedStatement interface adds methods for setting input parameters (binding variable|markers), see JDBC - PreparedStatement (bind variable, parameter markers)
Type of SQL and type of execute method
The method used to execute a Statement object depends on the type of SQL statement being executed. If the Statement object is:
- unknown, the method execute should be used.
Statements may also be batched, allowing an application to submit multiple statement as a single unit of execution.
The setQueryTimeout method may be used to specify the minimum amount of time before a a JDBC driver attempts to cancel a running statement. A JDBC driver must apply this limit to the execute, executeBatch, executeQuery and executeUpdate methods.