Jdbc - Statement

1 - About

SQL - Statement (Type)

3 - Creation

Statement objects are created by Connection objects

Connection conn = dataSource.getConnection(user, passwd);
Statement stmt = conn.createStatement()

4 - Type

The Statement interface defines methods for executing SQL statements.

There is also two subclasses:

5 - 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:

  • an SELECT SQL query returning a ResultSet object, the method executeQuery should be used. See ResultSet#example
  • a DDL statement or a DML statement returning an update count, the method executeUpdate should be used. Ex: Insert, Update, Create as select,…
  • unknown, the method execute should be used.

6 - Batch

Statements may also be batched, allowing an application to submit multiple statement as a single unit of execution.

7 - Property

7.1 - Timeout

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.

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap