Create a Data Source for a DB System Database

Use the WebLogic Server Administration Console to create a data source and establish a connection with an Oracle Cloud Infrastructure Database (DB System).

The DB System must allow your Oracle WebLogic Server for OCI domain to access the database listen port (1521 by default). Update the network security group that is assigned to the database, or update the security lists for the subnet on which the database was created, if necessary. See Security Rules for the DB System.

Verify the PDB Name

You need the PDB name if you have a 12c database in your DB System.

If you did not specify a PDB name when you created the 12c database, the default PDB name could be the database name appended with _pdb1. For example: <db_name>_pdb1

To verify you have the correct PDB name:

  1. Open an SSH connection to the database node.
  2. Use SQL*Plus to connect to the database as the sys user.
  3. Execute the command:
    show pdbs

Configure a Data Source for a DB System Database

You use the WebLogic Server Administration Console to create a Java Database Connectivity (JDBC) data source for the DB System database.

  1. Access the WebLogic Server Administration Console.
  2. In the Change Center box, click Lock & Edit.
  3. In the Domain Structure box, expand Services (by clicking the + next to it) and click Data Sources.
  4. On the Summary of JDBC Data Sources page , click New, and then select Generic Data Source.
  5. On the first page of the Create a New JDBC Data Source wizard, do the following:
    1. In the Name field, enter a name for your data source.
    2. In the JNDI Name field, enter a name.
    3. In the Database Type dropdown list, accept the default value Oracle.
  6. On the second page of the wizard, in the Database Driver dropdown list, select the value that's appropriate for your domain version.
    For example, select *Oracle's Driver (Thin) for Service connections; Versions:Any for a 12c domain.
  7. On the third page of the wizard, accept all options.
  8. On the fourth page of the wizard, do the following:
    1. Enter the Database Name and Host Name. Use the appropriate format for your database version and type.
      Database Version Database Type Database Name Host Name

      12c

      VM

      <pdb_name>.<db_domain>

      <db_hostname>-scan.<db_domain>

      12c

      Bare Metal

      <pdb_name>.<db_domain>

      <db_hostname>.<db_domain>

    2. In the Port field, enter the database listen port number (1521 by default).
    3. In the Database User Name field, enter a user who has been granted access to the database.
    4. In the Password field, enter the password for the database user and re-enter the password in Confirm Password field.
  9. On the fifth page of the wizard, verify that the URL has the appropriate format based on your database version and type:
    Database Verion Database Type URL

    12c

    VM

    jdbc:oracle:thin:@//<db_hostname>-scan.<db_domain>:<db_port>/<pdb_name>.<db_domain>

    12c

    Bare Metal

    jdbc:oracle:thin:@//<db_hostname>.<db_domain>:<db_port>/<pdb_name>.<db_domain>

  10. 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. For example, make sure there is a / after the port number. If there are no errors in the entries and the test still fails, make sure that your database is running.
    • The connection is successful when the message Connection test succeeded is displayed.
  11. On the last page of the wizard, select the target for the JDBC data source and then click Finish.
  12. In the Change Center, click Activate Changes.