Using Oracle 9i JDBC


  1. Check the JDBC Help Pages.

  2. Modify the .bashrc File. .bashrc is the file read and executed each time a bash, which is the default shell used by gandalf, is started. To use Oracle JDBC, you need to set environment variables in ~/.bashrc file by including the following commands:

    ~/.bashrc
    export  PATH=${PATH}:/home:/usr/bin:/usr/java/bin:/usr/java/sdk/bin
     
    CLASSPATH=.:/home/project/oracle/OraHome1/jre/1.1.8 
    CLASSPATH=$CLASSPATH:/home/project/oracle/OraHome1/jlib 
    CLASSPATH=$CLASSPATH:/home/project/oracle/OraHome1/jdbc/lib/classes12.zip 
    CLASSPATH=$CLASSPATH:/home/project/oracle/OraHome1/jdbc/lib/nls_charset12.zip 
    CLASSPATH=$CLASSPATH:/home/project/oracle/OraHome1/sqlj/lib/runtime.zip 
    CLASSPATH=$CLASSPATH:/home/project/oracle/OraHome1/sqlj/lib/translator.zip 
    CLASSPATH=$CLASSPATH:/home/project/oracle/OraHome1/ord/jlib 
    CLASSPATH=$CLASSPATH:/home/project/oracle/OraHome1/ord/ts/jlib 
    CLASSPATH=$CLASSPATH:/home/project/oracle/OraHome1/rdbms/jlib 
    CLASSPATH=$CLASSPATH:/usr/j2se/bin 
     
    export CLASSPATH 
     
    export ORACLE_SID=aero
    export ORACLE_HOME=/home/project/oracle/OraHome1

    After changing the .bashrc file, you may exit the gandalf and re-enter it to have the environment variables and shell options set.


  3. Create a JDBC Program. For example, create a program named MyJDBC.java . Two sample JDBC programs can be found from EnterCustomer.java and ListCustomers.java.


  4. Compile and Run the Program.
      gandalf> /usr/bin/javac MyJDBC.java
      gandalf> /usr/bin/java  JDBCTest
    Assume the Java compiler creates a class JDBCTest.class .