How to Use JDBC
    Main Page
    Lab Hardware
    Lab Software
 

In the instructions below, substitute your UW Net ID wherever you see "uwnetid".

Last updated: 9 Jan 2008

JDBC Overview

JDBC is the Java Database Connectivity API, which allows a Java program to access data stored in tabular form, such as those in relational databases and spreadsheets. Typically, a database driver is written by the database vendor and it is implemented as a class which is loaded prior to using the JDBC methods it provides. The driver and supporting classes and information are typically packaged in a jar file.

JDBC Drivers in the Labs

JDBC drivers for some DBMSes have been installed in the labs for your convenience. If they are not in a CLASSPATH environment variable, you will need to either set one or specify all classpaths as a parameter to the java command when running your application.

Here is how you can tell what your CLASSPATH variable is set to:

  • Windows Command Shell

    echo %classpath%
      

    Individual paths are separated by semicolons (";").

  • Unix/Linux

    Note that case is important.

    echo $CLASSPATH
      

    Individual paths are separated by colons (":").

For each of the DBMSes, these are the classpaths needed (don't forget to add '.' for the current directory):

DBMS Platform Location Comment
DB2 Windows G:\jdbc\db2\db2jcc.jar;G:\jdbc\db2\db2jcc_license_cu.jar The path separator may need to be "/", not "\"
Linux /usr/java/tools/db2/db2jcc.jar:/usr/java/tools/db2/db2jcc_license_cu.jar Already present in CLASSPATH on repos/cssgate
Firebird Windows G:\jdbc\firebird\jaybird-full-2.1.1.jar The path separator may need to be "/", not "\"
Linux /usr/java/tools/firebird/jaybird-full-2.1.1.jar Already present in CLASSPATH on repos/cssgate
MySQL Windows G:\jdbc\mysql\mysql-connector-java-5.0.7-bin.jar The path separator may need to be "/", not "\"
Linux /usr/java/tools/mysql/mysql-connector-java-5.0.7-bin.jar Already present in CLASSPATH on repos/cssgate
SQL Server 2005 Windows G:\jdbc\sqlserver\sqljdbc_1.2\enu\sqljdbc.jar The path separator may need to be "/", not "\"
Linux $MSJDBC_HOME/sqljdbc.jar Already present in CLASSPATH on repos/cssgate

DBMS Connection String Driver
DB2 com.ibm.db2.jcc.DB2Driver jdbc:db2://iai-db.insttech.washington.edu:50100/dbname
Firebird org.firebirdsql.jdbc.FBDriver jdbc:firebirdsql://repos.insttech.washington.edu:3050//home/firebird/uwnetid/dbname
MySQL on Repos com.mysql.jdbc.Driver jdbc:mysql://repos.insttech.washington.edu/dbname
MySQL on iai-db com.mysql.jdbc.Driver jdbc:mysql://iai-db.insttech.washington.edu/dbname
SQL Server 2005 com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc:sqlserver://iai-db.insttech.washington.edu;instanceName=SQLSERVER;databaseName=dbname

Change Log

9 Jan 2008 Updated driver for SQL Server 2005 to 1.2.
12 Sep 2007 Updated drivers, removed Oracle.
13 Sep 2006 Added variations on MySQL for different servers.
12 Sep 2006 Changed paths for latest versions, and invocation for SQL Server 2005
2 Jan 2006 Changed paths for latest versions, consistent between Windows and Linux, and fixed longstanding error in SQL Server class path
1 Feb 2005 Fixed Oracle path
8 Oct 2004 Original document


Hours  |  Support Information  |  News  | 
Policies  |  Emergencies