|
Prerequisites Skeleton Code
This exercise walks you through the steps to create an application that connects to a JDBC data source, using the JDBC-ODBC Bridge. It basically duplicates the steps in the JDBCTest Introduction exercise.
Perform the following tasks:
java.sql package.
Before you can connect to the database, register the JDBC driver. As in the previous example, you are going to use the JDBC-ODBC bridge provided with the JDK. The registration process involves loading the class. In this case, the driver
name is the Use The class must be locatable in the CLASSPATH. This should not be a problem because this driver is part of the JDK distribution. Once you have the driver registered, you can use it to connect to the database. This is done through the
After connecting to the database, you can fetch the database metadata through the
To truly duplicate JDBCTest, once you have the database metadata, print out all the information available. As a cautionary note, not all existing JDBC drivers provide database metadata. The Imaginary mSQL driver does not. If you are using an incomplete JDBC driver, check for null before examining the database metadata.
When you have finished examining the database metadata, close the connection via
the
Copyright © 1996 Magelang Institute. All Rights Reserved. | ||||
|
| ||||||||||||