JDBC and mySQL

One possible driver for using mySQL with JDBC is Connector/J from MySQL A/B (the makers of mySQL). An example of how this driver is loaded in Java is given in the first lines of this JDBC example, which produces the following output when run on the data from Exercise 5.2.1. Further information on the driver can be found in the README file included in the Connector/J distribution.

The Connector/J driver has been installed on the computer system of the department. To use it, you will need to tell Java where to find it. This is done by setting the environment variable CLASSPATH to include the path to the driver. If you are using the bash shell, do it like this:

     export CLASSPATH=.:/home/java/Lib/mysql-connector.jar
If you are using the tcsh or the csh shell, do it like this:
     setenv CLASSPATH .:/home/java/Lib/mysql-connector.jar
To find out which shell you are using, type
     echo $SHELL
To avoid doing this each time you log in, you can include this command on a line in a textfile with a name ending in .rc, and place the file in the proper configuration directory on your computer account. For the bash shell, this directory is
     ~/.daimi-setup/bash/bashrc.d/
If you are using e.g. the tcsh, put the file in the analogously named directory. More information on controlling the setup of your account can be found at the reference for the Daimi Setup.


Page maintained by Rolf Fagerberg <rolf@brics.dk>.