Sun Java Solaris Communities My SDN Account Join SDN
 
Tutorials & Code Camps

Connecting with Properties

 

Training Index


[Table of Contents]

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)
  2. KeyValue
    datasource.namecontains the name of the ODBC datasource
    datasource.usernamecontains the username to access datasource
    datasource.passwordcontains the password of odbc.username
  3. Import the JDBC package.
  4. Load the sun.jdbc.odbc.JdbcOdbcDriver class.
  5. Create a Connection to the DriverManager.
  6. Examine the database metadata to display the name and version of the database and driver.
  7. 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 © 1996 Magelang Institute. All Rights Reserved.