Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information JDC Resources DukeDollars

Java Cup Logo

JDC Home Page

JDC Applets
(chat, newsreader, calendar)

Log Out

Online Training
shadowSearchFAQFeedback

Course Notes Table of Contents | Exercises
JDBC Short Course Index | Online Training Index

Help: Using JDBCTest
Working Applet | Help
Solution

Help is available for each task, or you can go straight to the source code, which is one particular solution.

Task 1

Run JDBCTest. (java JDBCTest).

Ensure the JDBCTest package is installed, and the classes are in CLASSPATH.

Task 2

After starting up, the first thing you see is a splash screen. Select Press Here to Continue.

Task 3

To connect to the database, you need to first register the JDBC driver. You are going to use the JDBC-ODBC bridge provided with the JDK, but you can get drivers for non ODBC sources.

From the main screen, select Register Driver, under the Driver menu.

Task 4

This brings up the Get Driver URL window. Because you are using the Sun provided bridge, just press OK. If you were using a third party driver, you would enter that name here and it would need to be located in your CLASSPATH.

Task 5

Once you have registered the driver, you can use it to connect to the database.

Select Connect to DB under the Connection menu.

Task 6

This brings up the Select A Database window. To connect to the datasource use the URL in the Database text field. When you use the JDBC-ODBC bridge, the URL begins with the string jdbc:odbc: followed by the datasource name. If using a different driver, the URL still begins with jdbc:, but the remainder of the URL is specific to the driver.

Change the string dBASEfile to the name of the datasource you are using. Enter a username and password if necessary.

Task 7

You will see a Connection window displayed, saying "Connection Established" within the JDBC/Database Output text area. If this is not displayed, verify datasource name, username, password, and setup of ODBC source. If you connect again, another Connection window will appear with a different colored background.

Task 8

Now that you are connected, you want to find out information about the database you are using. This information is called metadata. To get the database metadata, select Get DB Meta Data under the Connection menu.

Task 9

The output area should say getMetaData() Succeeded., but where is it? To see the results, you need to select Show Meta Data under the MetaData menu.

Task 10

You will see the output in the JDBC/Database Output text area. Scroll through the results to see the many different things you can find out about the datasource. Every type of data source will display different information. When you have time, connect to an Access datasource and compare the results. When you are finished looking, quit out of JDBCTest by selecting Quit from the File menu of the JDBCTest Tool window.



Copyright © 1997 MageLang Institute. All Rights Reserved
May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved