4 Connecting to Oracle Database Manually

The following sections describe establishing a connection to Oracle Autonomous Database manually without any build tool:

Topics:

4.1 Downloading JDBC Driver and other JARs

This section lists the steps to download JDBC drivers and other JARs.

Make sure to complete all the steps from the Prerequisites section.
Download the 19c version of ojdbc8-full.tar.gz from OTN and unzip the contents to your classpath.

Note:

ojdbc8-full.tar.gz contains the latest JDBC drivers: ojdbc8.jar, ucp.jar (required JAR for using UCP as a client-side connection pool), oraclepki.jar, osdt_core.jar, and osdt_cert.jar. These JARs are required for using Oracle Wallets while connecting to Oracle Autonomous Database.

4.2 Building and Running a Sample Java Program

This section lists the step to build and run a sample Java program.

  1. Compile the Java program.
    Make sure to provide the correct path for the required JARs in the classpath.
    javac -classpath ./lib/ojdbc8.jar:./lib/ucp.jar:/lib/oraclepki.jar:./lib/osdt_core.jar:./lib/osdt_cert.jar com/oracle/jdbctest/ADBQuickStart.java
  2. Run the sample Java program.
    Make sure to provide the correct path for the required JARs in the classpath.
    java -classpath ./lib/ojdbc8.jar:./lib/ucp.jar:/lib/oraclepki.jar:./lib/osdt_core.jar:./lib/osdt_cert.jar:. com.oracle.jdbctest.ADBQuickStart
Sample Output:

The screenshot below shows the queried rows, along with a success message:


Sample Output

Note:

If you connect to Oracle Autonomous Database from behind a firewall, you will likely encounter a connection timeout error. Make sure to be outside the firewall while running this sample or update the tnsnames.ora file to use an HTTPS proxy.

See Also:

Using Oracle Autonomous Database Serverless for more information.