Connect an Oracle Java Cloud Service Instance to an Application Database

After you provision the service instance, you can create new data sources that enable you to connect to either an Oracle Autonomous Database (Oracle Autonomous Transaction Processing) or an Oracle Cloud Infrastructure database.

Topics:

Connect to an Oracle Autonomous Database

You can create an Oracle Autonomous Database (Oracle Autonomous Transaction Processing) using the Oracle Cloud Infrastructure Console, then provision an Oracle Java Cloud Service instance with the Oracle Autonomous Database for the schema infrastructure database, but not the application database. After you provision the Oracle Java Cloud Service, you can configure an additional data source that enables you to connect the provisioned service instance to an Oracle Autonomous Database.

Topics

Download the Oracle Autonomous Database Wallet

The first step in connecting an Oracle Autonomous Database (Oracle Autonomous Transaction Processing) is to download the database's wallet file, which contains client credentials.

Oracle wallet files are downloaded from Oracle Autonomous Database by a service administrator. If you are not an Oracle Autonomous Database administrator, ask your administrator to provide you with the wallet file.

You must first create an Oracle Java Cloud Service instance and an Oracle Autonomous Database in the same region.
  1. Sign in to access the Oracle Cloud Infrastructure Console, if it's not open already. If you are currently in the Oracle Java Cloud Service Console, select Compute from the Navigation menu and sign in.
  2. On the Oracle Cloud Infrastructure Console, select the region in which your Oracle Autonomous Database and Oracle Java Cloud Service instance are located.
  3. Select Autonomous Transaction Processing from the Oracle Database section of the Navigation menu.
  4. Select the Compartment that contains your Oracle Autonomous Database.
  5. Click the name of the Oracle Autonomous Database you want to connect to your service instance.
  6. On the Oracle Autonomous Transaction Processing details page, click DB Connection.
  7. On the Database Connection page, click Download.
  8. In the Download Wallet dialog, enter a wallet password in the Password field and confirm the password in the Confirm Password field.
  9. Click Download to save the wallet zip file.

Copy and Unpack the Wallet

After you download the wallet, copy and unpack the wallet to the Administration Server node. If your service instance contains multiple nodes, copy the wallet to each node.

Performing the following steps ensures that each node has client credentials.
First, make a note of the IP address of your Oracle Java Cloud Service Administration Server's IP address. You can locate the IP address on the Overview page for your Oracle Java Cloud Service instance.
  1. Use scp to copy the wallet file to the service instance's Administration Server node.
    scp -i ~/<private_key> /<example_zip_directory>/wallet_<ATP_db_name>.zip opc@<admin_server_ip>:/tmp
  2. Use ssh to access the node where you copied the zip file.
    ssh -i ~/<private_key> opc@<admin_server_ip>
  3. Change the ownership of the wallet file to oracle.
    sudo chown oracle:oracle /tmp/wallet_<ATP_db_name>.zip
  4. Change to user oracle.
    sudo su oracle
  5. Create a directory where you can copy the wallet zip file. Oracle recommends placing the wallet in the domain home directory.
    mkdir /u01/data/domains/<service_instance_domain>/config/<example_directory>
  6. Change directories to the directory you just created.
    cd /u01/data/domains/<service_instance_domain>/config/<example_directory>
  7. Unpack the wallet zip file.
    unzip /tmp/wallet_<ATP_db_name>.zip
  8. Repeat these steps for all other Managed Server nodes.

Create a Data Source in the WebLogic Server Console

After you download the wallet file and copy it to all servers in the instance, you can create a data source in the WebLogic Server Console that enables you to connect your Oracle Java Cloud Service instance to your Oracle Autonomous Database (Oracle Autonomous Transaction Processing).

  1. Access the Oracle Java Cloud Service console.
  2. From the Instances page, click the Manage this InstanceManage this instance icon icon next to the service instance, and then select Open WebLogic Server Administration Console.
  3. Sign in to the WebLogic console as the WebLogic Administrator. Enter the same WebLogic Administrator credentials that you specified when you created the service instance.
    The Oracle WebLogic Server Console is displayed.
  4. In the Change Center box at the top left corner of the page, click Lock & Edit.
  5. In the Domain Structure box, expand Services (by clicking the + next to it) and click Data Sources. The Summary of JDBC Data Sources page is displayed.
  6. Click New, and then select Generic Data Source.
  7. In the first page of the Create a New JDBC Data Source wizard, enter any values for Name:
    1. In the Name field, enter any name for your data source.
    2. In the JNDI Name field, enter any name.
    3. In the Database Type drop-down list, accept default type Oracle.
    4. Click Next.
  8. On the second page, accept all options and click Next.
  9. On the third page, do the following:
    1. In the Database Name field, enter the name of your Oracle Autonomous Database.
    2. In the Host Name field, enter the host name for the Oracle Autonomous Database. If you don't know the host name, open the tsnames.ora wallet file, and locate the host name there.
    3. In the Port field, enter 1522.
    4. In the Database User Name field, enter ADMIN.
    5. Enter a password, and then confirm it.
    6. Click Next.
  10. On the fourth page, update the URL.
    1. View file tnsnames.ora in the wallet zip file.
    2. Select an appropriate database service, which uses the format <database_name>_<priority>. For example:
      db1_high = (description=
          (address=(protocol=tcps)(port=1522)(host=mydb.example.com))(connect_data=(service_name=abcd1234_db1_high.mydb.example.com))(security=(ssl_server_cert_dn=
          "CN=mydb.example.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US"))   )
    3. Copy the service description, which is all of the text after the equals (=) character:
      (description= <service_description>)
    4. Replace the current URL with the following one:
      jdbc:oracle:thin:@<copied_service_description>

      For example:

      jdbc:oracle:thin:@(description=
          (address=(protocol=tcps)(port=1522)(host=mydb.example.com))(connect_data=(service_name=abcd1234_db1_high.mydb.example.com))(security=(ssl_server_cert_dn="CN=adwc.uscom-east-1.oraclecloud.com,OU=Oracle
          BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))

      Note:

      Ensure that all the URL text is all on the same line. The text in the tnsnames.ora file is not written on the same line, so exercise caution.
  11. On the same page where you updated the URL, update the properties in the Properties field with the following information and click Next:
    
    user=ADMIN
    oracle.net.tns_admin=/u01/data/domains/<location_of_unpacked_wallet_zip>/config/<example_directory> 
    oracle.net.ssl_version=1.2
    javax.net.ssl.trustStore=/u01/data/domains/<location_of_unpacked_wallet_zip>/config/<example_directory>/truststore.jks
    oracle.net.ssl_server_dn_match=true
    javax.net.ssl.keyStoreType=JKS
    javax.net.ssl.trustStoreType=JKS
    javax.net.ssl.keyStore=/u01/data/domains/<location_of_unpacked_wallet_zip>/config/<example_directory>/keystore.jks              
    javax.net.ssl.keyStorePassword=<WalletPassword> 
    javax.net.ssl.trustStorePassword=<WalletPassword>
  12. One the fifth page of the wizard, click Test Configuration to verify if a connection to the database can be established based on the information that you provided.
    • If the connection test fails, click Back and review the entries that you made for the data source and correct any errors. If there are no errors in the entries and the test still fails, make sure that your database is running.
    • If the message Connection test succeeded is displayed, click Next.
  13. On the last page of the wizard, select All Servers in the Cluster in the Select Targets table and click Finish.
  14. In the Change Center, click Activate Changes.

Connect to an Oracle Cloud Infrastructure Database

You can create an Oracle Cloud Infrastructure database using the Oracle Cloud Infrastructure Console, then provision an Oracle Java Cloud Service instance with the Oracle Cloud Infrastructure database for the schema infrastructure database, but not for the application database. After you provision the Oracle Java Cloud Service instance, you can configure an additional data source that enables you to connect the provisioned service instance to an Oracle Cloud Infrastructure database.

For details, see the Connect an Oracle Java Cloud Service Instance to an Oracle Cloud Infrastructure Database System tutorial.

Note:

In addition to creating a data source, you must also create a security list with the stateless ingress rule to allow the incoming traffic from the Oracle Java Cloud Service instance to the Oracle Cloud Infrastructure database.