Welcome Java Developers!
In this short video you’ll learn how to run an example Java app that
connects to and queries
an Autonomous Transaction Processing database instance using Oracle’s jdbc driver.
The account can be an Always Free or purchased account, both follow the same steps.
The 4 main steps for connecting a Java app are:
Having access to an ATP database instance with at least one authorized user
Downloading the database instance wallet
Editing the java app to include connection information found in the wallet and the username
and password of an authorized instance user.
Editing the POM file to pull in the Oracle jdbc driver and companion jar files
In this demonstration, I already have access to an ATP account with a database instance
named demo
and a jdbctest user authorized to access the instance.
Next, the demo wallet is downloaded to a local PC or Mac.
An Apache Maven project named jdbctest has already been created.
The UCPSample java app and POM file are downloaded from Github to the Maven jdbctest project.
The app is edited to include the location of the wallet, and the username
and password of the jdbctest user.
The POM file is edited to include dependencies that pull in the Oracle jdbc driver and companion
jar files from Apache Maven Central.
Finally Maven is used to compile and run the java app.
So, let’s get started.
Step 1, we need an ATP account with a database instance and authorized user.
To make sure the demo instance is available and running, from your Oracle cloud account,
open the navigation menu,
and select Autonomous Transaction Processing.
Make sure it’s available and running.
Step 2, download the credentials for the demo wallet.
Click on the instance.
Click on DB connection then Download Wallet.
Enter a password for this wallet
and download it to a secure location your java client can access
unzip the file
Step 3, edit the java app to include connection information and user credentials.
Go to Github to download the sample app and the POM file.
Search for oracle-db-examples.
Then select it.
Go to java, jdbc, then BasicSamples.
Download UCPSample.java and the POM file to your Maven project folder.
Open the app for editing.
Before the import statements, add the package com.oracle.jdbctest.
Edit DB_URL to reference the ATP demo instance and location of the ATP wallet.
Change dbname_alias to demo_high.
This is found in the tnsnames.ora file which was part of the wallet we downloaded earlier.
Modify tns_admin to reference the location and name of the wallet.
Change DB_USER to jdbctest and change DB_PASSWORD to the password defined for this user when
it was created.
Users can be created from the demo Service Console.
Save your changes.
Step 4, edit the POM file downloaded earlier to reference the Oracle JDBC driver and pull
in the companion Jar files.
Open the POM file for editing.
Make sure the dependency for com.oracle.database.jdbc is included in the file.
Also make sure the JDK version is the same as the version installed on your local machine.
Save any changes.
Now we’re ready to compile and run the java app.
From the project folder run the Maven clean command
and then compile.
Enter the Maven command to run the compiled java app.
The app connects to the demo instance,
builds an emp table,
inserts 2 data records and returns them for display.
Learn more at cloud.oracle.com and the ATP Oracle Help Center.
Thank you for watching