Homework 3

There is a database on limani.cs.uchicago.edu, called cspp51024.  In this database, there is a table called pollution.  You will use this table for this homerwork assignment.

Add the following command to your .bashrc file:

export ORACLE_DB='(description=(address=(protocol=tcp)(host=limani.cs.uchicago.edu)(port=1521))(connect_data=(service_name=cs51024.cs)))'

Exit your shell and log back in again.  Type:

echo $ORACLE_DB

and verify that it is set correctly. 

Also, you must also set the following variables in your .bashrc:

export ORACLE_HOME=/packages/oracle/home/OraHome1/
export ORACLE_TERM=xterm

Also, you must ensure that the following directory is included in your PATH (on botev):

/packages/oracle/home/OraHome1/bin/

You must also ensure that the following entry is included in your CLASSPATH:

/home/matei/bin/ojdbc14.jar

You cannot log in to limani directly (via ssh limani...).    However, you can access the limani Oracle database server using sqlplus:

    1.  Using a text-based client:

a.) ssh into the following Sun machine:  botev.cs.uchicago.edu

b.) Run: 

    sqlplus cspp51035@${ORACLE_DB}

(the password can be found in the following file:  ~mark/pub/51035/oracle/password.txt).  You can view the contents of this file by typing:  cat ~mark/pub/51035/oracle/password.txt from any cluster machine (including botev).

c.) More information on using sqlplus and SQL is available here. (Please ignore "Getting an account" and "Logging-in" sections)

  1. Ask questions! Sun's JDBC tutorial  or Mark's JDBC slides might be helpful to understand what's going on. 

  2. Resources:
      JDBC Home Page
      JDBC tutorial
For this assignment, you are to do the following:

1.  Use JDBC to access the pollution table, and retrieve the contents of the table into a RecordSet.  

2.  Iterate through the RecordSet and store the each column of data into an individual java.util.Vector object.  Basically you will have 8 Vectors representing the data in each of the 8 columns of the database table.

3.  Add the entire virtual row content of each column Vector object into an appropriate Collection class (you choose which one you want to work with), so that you have a multidimensional array that accurately depicts the structure of the original database table.

4.  Iterate through your Collection and print out each row of the Collection.  The data printed out should match the contents of the original database table as depicted through a select * from pollution statement.

Tarball up your solution and email to the TA for verification of receipt.