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

Connecting with Properties
Working Applet | Help
Solution

Skeleton Code

This exercise results in an application that connects to an ODBC database through the JDBC-ODBC Bridge. You have to run it from the command line, rather than from a page in a browser. Also, you have to ensure that the database server is enabled.

Instead of hardcoding a datasource, username, and password in the program, an external file is used for this information. This is the method for the remaining exercises.

Perform the following tasks:

  1. Setup the file odbc.datasource in the current directory to have three key-value resources. (key=value)
    KeyValue
    datasource.namecontains the name of the ODBC datasource
    datasource.usernamecontains the username to access datasource
    datasource.passwordcontains the password of odbc.username

  2. Import the JDBC package.

  3. Load the sun.jdbc.odbc.JdbcOdbcDriver class.

  4. Create a Connection to the DriverManager.

  5. Examine the database metadata to display the name and version of the database and driver.

  6. Close the connection.

The task numbers above are linked to the step-by-step help page. Also available is a complete solution, which meets these requirements, and Expected Behavior.


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