You are on page 1of 2

JDBC

JDBC concepts
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: 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. 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.

Differences between client- and server-side JDBC


The difference between JDBC on the client and in the database server is in how a connection is established with the database environment. When you use client-side or server-side JDBC, you call the
Drivermanager.getConnection() method to establish a connection to the server.

For client-side JDBC, you use the Sybase jConnect JDBC driver, and call the Drivermanager.getConnection() method with the identification of the server. This establishes a connection to the designated server.

You might also like