Hi Edward,
JDBC API is bundled with JDK. So, When you download the JDK, you will get JDBC as well.
To mention some of the major differences found between these two APIs are as follows:
1.Moving the Cursor in Scrollable Result Sets
------------------------------------------------
In the JDBC 1.0 API, the only way to move the cursor was to call the method
next . But in JDBC 2.0 API you have many other ways to move the cursor. The counterpart to the method
next is the new method
previous , which moves the cursor backward
2.Making Updates to Updatable Result Sets
----------------------------------------
The new methods in JDBC 2.0 API, which JDBC 1.0 API doesnt have, for the ResultSet interface is:
insert a new row into ResultSet object,
delete an existing row from ResultSet object, or
modify a column value in ResultSet object.
3.Updating, Inserting and Deleting a Result Set Programmatically
----------------------------------------------------------------
Using the JDBC 1.0 API, the update statemnet would look something like this:
stmt.executeUpdate("UPDATE COFFEES SET PRICE = 10.99" +
"WHERE COF_NAME = FRENCH_ROAST_DECAF");
The following code fragment shows another way to accomplish the update, this time using the JDBC 2.0 API:
uprs.last();
uprs.updateFloat("PRICE", 10.99);
uprs.updateRow();
(Here uprs is the ResultSet object)
Update operations in the JDBC 2.0 API affect column values in the row where the cursor is positioned, so in the first line the ResultSet uprs calls the method
last to move its cursor to the last row . Once the cursor is on the last row, all of the update methods you call will operate on that row until you move the cursor to another row. The second line changes the value in the PRICE column to 10.99 by calling the method
updateFloat. This method is used because the column value we want to update is a float in the
Java programming language. To make the update take effect in the database and not just the result set, we must call the ResultSet method
updateRow.
Similarly, to insert a row, instead of using executeUpdate(...),
you should invoke the method
moveToInsertRow, then set a value for each column in the row. You do this by calling the appropriate
updateXXX method for each value and then call
uprs.insertRow().
Now, to delete a row, say 4th row from a table, you call:
uprs.absolute(4);
uprs.deleteRow();
This will remove fourth row from ResultSet object and also from the database.
4. Using Statement Objects for Batch Updates
------------------------------------------------
In the JDBC 1.0 API, Statement objects submit updates to the database individually with the method executeUpdate. Multiple executeUpdate statements can be sent in the same transaction, but even though they are committed or rolled back as a
unit, they are still processed individually. The interfaces derived from Statement, PreparedStatement and CallableStatement, have the same capabilities, using their own version of executeUpdate.
With the JDBC 2.0 API, Statement, PreparedStatement, and CallableStatement objects have the ability to maintain a list of commands that can be submitted together as a batch. They are created with an associated list, which is initially empty. You can add SQL commands to this list with the method
addBatch, and you can empty the list with the method
clearBatch. You send all of the commands in the list to the database with the method
executeBatch.
5.Using SQL3 Datatypes
-----------------------
The datatypes commonly referred to as SQL3 types are the new datatypes being adopted in the next version of the ANSI/ISO SQL standard. The JDBC 2.0 API provides interfaces that represent the mapping of these SQL3 datatypes into the Java programming language. With these new interfaces, you can work with SQL3 datatypes the same way you do other datatypes.