Using Oracle Database 21c JDBC


  1. Check the JDBC Help Pages.

  2. Apply for a UND Engineering Linux Account.

  3. Use VPN (Virtual Private Network) to connect to the UND networks.
  4. You may not need to do this if you are on campus.

  5. Log in to the Linux server: undcemcs02.und.edu .

  6. Modify the ~/.bash_profile file for the first and only time.
  7. ~/.bash_profile is the personal initialization 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 ~/.bash_profile file by including the following commands:

    ~/.bash_profile
    # To set up the Oracle environment for your shell account
    CLASSPATH=.:/usr/lib/oracle/23/client64
    CLASSPATH=$CLASSPATH:/usr/lib/oracle/23/client64/lib/ojdbc8.jar
    CLASSPATH=$CLASSPATH:/usr/lib/oracle/23/client64/lib/ottclasses.zip
    export CLASSPATH

    Enter the following command after updating the .bash_profile file:
      shell> source ~/.bash_profile 
    My complete .bash_profile can be found from here.

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

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

    shell>

    undcemcs02>