Learn how to build a Linux Java application server and connect it to an Oracle Autonomous database.
We need the Java Development Kit (JDK) and I'm using version 13 for this workshop. You can install it with this command
sudo yum install java-latest-openjdk -y
Check everything works
java --version
Download the code
wget --content-disposition https://github.com/vmleon/OracleATPGettingStarted/blob/master/store/java.zip?raw=true
Unzip the file and change the directory to java
unzip java.zip && cd java
There is a config file template we need to copy with the proper name to be picked by the application
cp src/main/resources/config.properties.template src/main/resources/config.properties
Edit the file so it matches your settings vim src/main/resources/config.properties
db.url=jdbc:oracle:thin:@atpworkshop_HIGH?TNS_ADMIN=/home/opc/wallet/
db.user=ADMIN
db.password=Welcome_123!
This is a Gradle project, which means we can install dependencies and run the code all in one simple command.
./gradlew run
It will take some time doing the downloads, compilation, etc but you should see something like this
Driver Version: 19.3.0.0.0
Database Username is: ADMIN
Database: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
There is a message
SEVERE: attempt to configure ONS in FanManager failed with oracle.ons.NoServersAvailable: Subscription time out
. I'm working on it.
Feel free to inspect the code on Github in the folder src/java.
All the meat is in src/java/src/main/java/page/cateam/atp/Database.java
!
Well done, you configure the Java app to create a connection and retrieve the banner of the Autonomous Database.
Congratulations! You are ready to go to the next Lab!
<< Prev | home | NEXT >>>>>