Slide 13.13: Using Perl
  Slide 13.15: Using Unix shell
  Home


Using JDBC at the shell Server


  1. 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:

     ~/.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.


  2. 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.


  3. 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 .