Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » SQL Anywhere JDBC API » Introduction to JDBC

Choosing a JDBC driver Next Page

JDBC program structure

The following sequence of events typically occurs in JDBC applications:

  1. Create a Connection object    Calling a getConnection class method of the DriverManager class creates a Connection object, and establishes a connection with a database.

  2. Generate a Statement object    The Connection object generates a Statement object.

  3. Pass a SQL statement    A SQL statement that executes within the database environment is passed 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 exposes it one row at a time (similar to the way a cursor works).

  4. Loop over the rows of the result set    The next method of the ResultSet object performs two actions:

  5. For each row, retrieve the values    Values are retrieved for each column in the ResultSet object by identifying either the name or position of the column. You can use the getData method to get the value from a column on the current row.

Java objects can use JDBC objects to interact with a database and get data for their own use.