Oracle by Example brandingAutonomous Transaction Processing (ATP), SpringBoot and JDBC

section 0Before You Begin

This tutorial shows you how to connect to an ATP Database using JDBC and Spring.

Background

An ATP Database enables convenience and ease of use. It allows autonomous backups and patching, zero downtime scaling, and easy provisioning.

The following OBE provides step by step instructions on how to connect to an ATP using SpringBoot, which uses JDBC and UCP.

SpringBoot enables you to create standalone Spring based applications that are easy to set up and run.

Visit the SpringBoot website for more information: SpringBoot

This application accesses the EMP table in the database, and displays employee names in the table.

What Do You Need?

  • An integrated development environment such as Eclipse, Netbeans, IntelliJ, or JDeveloper.
  • Access to application code on Github.
  • An Oracle Cloud account (or access to an ATP account).
  • Download the wallet files using your Cloud credentials (or, client credentials to connect to ATP)
  • An EMP table in the database, populated with data. If needed, use script on Github to create and populate this table.
  • spring-boot-1.4.2.jar files, and commons-logging-1.2.jar files:
  • Note: Download the JAR files here:  SpringBoot

  •  JDBC JAR Files (Release 18.3):
    • ojdbc8.jar
      ons.jar
      oraclepki.jar
      osdt_cert.jar
      osdt_core.jar
      ucp.jar

    Note: Download the JAR files here: JDBC JAR Files


  •  Spring JAR Files (Release 4.3.4):
    • spring-aop-4.3.4.RELEASE.jar
      spring-beans-4.3.4.RELEASE.jar
      spring-boot-1.4.2.RELEASE.jar
      spring-context-4.3.4.RELEASE.jar
      spring-core-4.3.4.RELEASE.jar
      spring-expression-4.3.4.RELEASE.jar
      spring-jdbc-4.3.4.RELEASE.jar
      spring-tx-4.3.4.RELEASE.jar

    Note: Download the list of JAR files here: Spring JAR Files

Download application code from Github.


section 1Download and install Application and IDE

  1. Ensure that you have an IDE running. In this example, we are using Eclipse.
  2. Note: You may also use NetBeans, IntelliJ, or JDeveloper.

  3. Install the application code that you downloaded from Github.

section 2Open the Java code in an IDE

  1. Download the application code from Github.
  2. Open a new project in Eclipse. Go to File. Click New, and then select Project.

section 3Place the JAR files in the appropriate directory

  1. Ensure that the JDBC, Spring and commons-logging JAR files are present in the classpath/buildpath.

In this example, the JAR files are stored in the following location: D:\ATP_OBE\SpringBoot_JDBC_UCP_JARS\Spring_Boots_Jars\.

JAR files required for the application.
Description of the illustration jars.png


section 4Update the URL and credentials

  1. Open the HelloAppConfig.xml file.
  2. HelloAppConfig.xml
    Description of the illustration helloappconfig.png
  3. Set the value of DB_URL to the destination on your local system, where you have downloaded the wallet.
  4. DB_URL="jdbc:oracle:thin:@jdbctest_medium?TNS_ADMIN=D:/ATP_OBE/wallet_JDBCTEST"

    Note: The wallet stores all information related to your database instance.

    This figure shows the credentials that the user has to enter. This includes URL, username and password.
    Description of the illustration url.png
  5. Set the DB_USER to jdbcuser.
  6. Enter the DB password.

section 5Test the code

  1. Once you have entered the credentials, go to Menu.
  2. Navigate to HelloApplication.java.
  3. Right click on the file. Select Run As. Then, select '1 Java Application'.

The code will compile and you will be able to view the output under the 'Console'.

Once the application is connected to the ATP Database, you will be able to view the data in the table.

Data present in the EMP table is displayed.
Description of the illustration final.png



more informationWant to Learn More?