How to Use JDBC with Firebird
    Main Page
    Lab Hardware
    Lab Software
 

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

Last updated: 12 Sep 2007

JDBC for Firebird

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.

Firebird is a commercial-quality open-source database management system (DBMS) that supports JDBC. The official JDBC driver for Firebird is called JBird or JayBird. It is a "Class 4 JCA-JDBC Driver".

A good but somewhat outdated source for documentation on how to use this driver can be found in the Jaybird FAQ.

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.

For Firebird:

Platform Location Comment
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

The Connection String

The release notes list how to register the driver with the driver manager, which effectively loads the driver so you can create a connection to the database that the driver supports:

try { // The newInstance() call is a work around for some // broken Java implementations Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance(); } catch (Exception E) { System.err.println("Unable to load driver."); E.printStackTrace(); }

A "connection string" is a URI for specifying how to access the database. The format for the connection string is well defined (an example is given later). However, various values are specific to the installation.

An empty Firebird directory in which to store your databases has already been created for you on the Repository Server. You will need to create a database (using isql or a GUI-based tool), which is just a file in that directory.

For example, after logging into the Repository Server (as, for example, user "johndoe"):

  1. /opt/firebird/bin/isql

    Starts Firebird's isql program.

  2. create database '/home/firebird/johndoe/test.fdb' user 'johndoe' password 'jddb';

    Create a database called 'test.fdb'. This is only done once.

  3. commit;

    Commit the creation of the database.

  4. connect '/home/firebird/johndoe/test.fdb' user 'johndoe' password 'jddb';

    Use this database as the default database.

  5. Create tables, etc.

The connection string requires the host, port, database, database user, and database user password:

  • host

    repos.insttech.washington.edu

  • port

    The port is 3050.

  • database name

    This is the path to your database, which is of the form: /home/firebird/uwnetid/filename

  • database user name

    This is your UW Net ID.

  • database user password

    The password is available from either faculty or lab staff.

For example, for a remote connection to cssgate.tacoma.washington.edu for UW Net ID "johndoe" with password "jddb", the connection string imbedded in the getConnection() method would be: Connection Conn = DriverManager.getConnection( "jdbc:firebirdsql://repos.insttech.washington.edu:3050//home/firebird/johndoe/test.fdb", "johndoe", "jddb");

...and the rest

The rest of the code is specific to the JDBC API, your database and table definitions, and the Firebird command set.

Change Log

12 Sep 2007 Updated for updated driver
2 Jan 2006 Updated for updated driver locations; updated old links
5 Oct 2004 Emphasize repos.insttech.washington.edu, changes due to Firebird 1.5 and JDBC driver
19 Oct 2002 Original document


Hours  |  Support Information  |  News  | 
Policies  |  Emergencies