Using Oracle Database 12c JDBC


  1. Check the JDBC Help Pages.

  2. Apply for a UND Engineering Linux Account.

  3. Log in to the Linux Server undcemcs02.und.edu .

  4. Modify the .profile File.
  5. .profile is the shell startup file and gets executed whenever you log in to undcemcs02. It is located in a user’s home directory and tilde slash (~/) is the beginning of a path to a file or directory below the user’s home directory. To use Oracle JDBC, you need to set environment variables in ~/.profile file by including the following commands:

    ~/.profile
    # To set up the Oracle environment for your shell account
    CLASSPATH=.:/usr/lib/oracle/12.1/client64
    CLASSPATH=$CLASSPATH:/usr/lib/oracle/12.1/client64/lib/ojdbc7.jar
    CLASSPATH=$CLASSPATH:/usr/lib/oracle/12.1/client64/lib/ottclasses.zip
    export CLASSPATH
    
    # To set up the Oracle environment for SQL*Plus
    export ORACLE_HOME=/usr/lib/oracle/12.2/client64
    export LD_LIBRARY_PATH=${ORACLE_HOME}/lib
    export PATH=${ORACLE_HOME}/bin:$PATH
    export CLASSPATH

    Enter the following command after updating the .profile file:
      undcemcs02> source ~/.profile 
  6. Create a JDBC Program.
  7. For example, create a program named MyJDBC.java . Two sample JDBC programs can be found from EnterCustomer.java and ListCustomers.java.

  8. Compile and Run the Program.
  9. Assume the Java compiler creates a class MyJDBC.class,
      undcemcs02> /usr/bin/javac MyJDBC.java 
      undcemcs02> /usr/bin/java  MyJDBC 
    where the Java compiler and interpreter are located at
    undcemcs02>

    undcemcs02>

    undcemcs02>




      A house divided against itself cannot stand.