Connect to Oracle Autonomous AI Database Using JDBC Without a Build Tool

You can establish a connection to Oracle Autonomous AI Database manually without any build tool.

Prerequisites

The following sections provide information about the tasks that you need to perform before connecting your Java applications to Oracle Autonomous AI Database using Oracle JDBC driver and Universal Connection Pool. Refer to the appropriate prerequisites depending on the authentication type selected during provisioning of your Autonomous Exadata VM Cluster (AVMC). By default, one-way TLS connections are enabled when you provision an AVMC. See Create an Autonomous Exadata VM Cluster for more information.

You can find the authentication type on the Details page of your AVMC. See View Details of an Autonomous Exadata VM Cluster for instructions.

Procedure

  1. Download the19c version of ojdbc8-full.tar.gz from OTN and unzip the contents to your classpath.

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

  2. 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
    
  3. 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 queried rows along with a success message are displayed, as shown in the following screen:

    Description of no_build_and_run.png follows

    Note: If you connect to Oracle Autonomous AI 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.