JDBC concepts and terminology

JDBC is a Java API and a standard part of the Java class libraries that control basic functions for Java application development. The SQL capabilities that JDBC provides are similar to those of ODBC and dynamic SQL.

The following sequence of events is typical of a JDBC application:

  1. Create a Connection object – call the getConnection( ) static method of the DriverManager class to create a Connection object. This establishes a database connection.

  2. Generate a Statement object – use the Connection object to generate a Statement object.

  3. Pass a SQL statement to the Statement object – if the statement is a query, this action returns a ResultSet object.

    The ResultSet object contains the data returned from the SQL statement, but provides it one row at a time (similar to the way a cursor works).

  4. Loop over the rows of the results set – call the next( ) method of the ResultSet object to:

  5. For each row, retrieve the values for columns in the ResultSet object – use the getInt( ), getString( ), or similar method to identify either the name or position of the column.