Jdbc - Statement

Jdbc Class Architecture

About

What are SQL Statements?

Creation

Statement objects are created by Connection objects

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

Type

The Statement interface defines methods for executing SQL statements.

There is also two subclasses:

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.

Batch

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

Property

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.





Discover More
Jdbc Class Architecture
JDBC (Java Database Connectivity)

JDBC – Java Database Connectivity is a Java API that provides access to most popular databases or to other tabular data sources. It provides methods for querying and updating data in a database. JDBC...
Jdbc Class Architecture
JDBC - Batch (Update|Statement) (DML|DDL)

The batch update facility allows multiple SQL statements to be submitted to a data source for processing at once. Submitting multiple SQL statements, instead of individually, can greatly improve performance....
Jdbc Class Architecture
JDBC - Callable Statement (Stored Procedure)

The CallableStatement objects interface adds methods to the statement interface for retrieving output parameter values returned from stored procedures. See java/sql/CallableStatementCallableStatement...
Jdbc Class Architecture
JDBC - PreparedStatement (bind variable, parameter markers)

in JDBC. The PreparedStatement interface extends Statement. See also: Parameter markers, represented by “?” in the SQL string, are used to specify bind variable (input values) to the statement...
Jdbc Class Architecture
JDBC - Resultset (SELECT|SQL query)

The java/sql/ResultSetResultSet interface encapsulates the results of an SQL query and implements a cursor API. Statements may also be batched, allowing an application to submit multiple updates to a data...



Share this page:
Follow us:
Task Runner