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:
Create a Connection object – call the getConnection( ) static method of the DriverManager class to create a Connection object. This establishes a database connection.
Generate a Statement object – use the Connection object to generate a Statement object.
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).
Loop over the rows of the results set – call the next( ) method of the ResultSet object to:
Advance the current row (the row in the result set that is being exposed through the ResultSet object) by one row.
Return a Boolean value (true/false) to indicate whether there is a row to advance to.
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.