Slide 10.9: Using Oracle9.2.0i on the server with an IP address 172.20.4.9
Slide 11.1: Oracle database management systems
Home

Using JDBC on the Server shell


  1. Check the JDBC Help Pages.

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

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

    After changing the .zshrc file, you may exit the shell 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.
      shell> /usr/bin/javac MyJDBC.java
      shell> /usr/bin/java  JDBCTest
    Assume the Java compiler creates a class JDBCTest.class .