Log into rack40 and set up DB2 environment (see Getting Started with DB2 for detailed instructions).
Copy example files and the DB2 JDBC driver to your home directory:
cp -r ~cps216/db2java ~
Create an example table in DB2:
cd ~/db2java db2 -tf DB2AppSetup.sqlThe script above will create an example table named employee in your database.
Change your working directory to the one containing example programs:
cd ~/db2java
Compile the example program:
javac DB2AppLocal.java
Run the example program:
java DB2AppLocal
Read DB2AppLocal.java to get an idea about how JDBC works. Pay attention to the driver class name and connection URL string, as they are different for local and remote connections.
Change your working directory to the one containing example programs:
cd ~/db2java
Compile the example program:
javac DB2AppRemote.java
Make sure ~/db2java/db2java.zip (this is the DB2 JDBC driver) is in your CLASSPATH.
Run the example program:
java DB2AppRemote <user> <password>Here, <user> and <password> should be what you use to log into rack40.
Read DB2AppRemote.java to get an idea about how JDBC works. Pay attention to the driver class name and connection URL string, as they are different for local and remote connections.