Connecting to Oracle 12c with a JDBC Driver
On-Premises
Redwood Platform ships with Oracle JDBC drivers. If you want to use a newer driver version, then you will need to upload Oracle JDBC drivers to a library and reference it in your Database object. See the Connecting to Oracle 12c with JDBC Driver in Library example below.
- Navigate to Configure > Admin > Security > Credentials.
- Click New.
- Select a Partition.
- Choose JDBC from the CredentialProtocol dropdown list.
- Enter a username and password in the Real User and Password fields.
- In the Endpoint field, enter
JDBC_Oracle12c_DB
. - Click Save & Close.
- Navigate to Configure > Admin > Manage Connectors > Databases.
- Click New.
- Select a Partition.
- Enter
JDBC_Oracle12c_DB
in the Name field. - Select Oracle Thin from the Jdbc Driver Class Name dropdown list.
- Select Jdbc Url > Advanced and enter
jdbc:oracle:thin:@ora12.example.com:1521/orcl
into the field. - Select an option from the Connection User dropdown list.
- Click Save & Close.
- Navigate to Configure > Control > Job Servers.
- Click New.
- Select a Partition.
- Enter
JDBC_Oracle12c_ProcessServer
in the Name field. - On the Services tab, click
and select JDBCService.
- On the Definition Types tab, click
and select JDBC.
- Click Save & Close.
- Navigate to Configure > Automate > Scripting tools > Shell.
- Paste the following code into the Shell script field and then click Run command.
Copy
{
Partition p = jcsSession.getPartitionByName("Example");
Database db = jcsSession.getDatabaseByName(p, "JDBC_Oracle12c_DB");
ProcessServer ps = jcsSession.getProcessServerByName(p, "JDBC_Oracle12c_ProcessServer");
ObjectReference objRef = ps.createObjectReference(db);
objRef.setName(Database.OBJECT_REFERENCE_NAME_JDBC_PROCESSSERVER);
jcsSession.persist();
}
Using a Library
Assume you want to connect to an Oracle database with the ojdbc7.jar
driver. The driver ships with the following info:
-
Name: Oracle Thin Client
-
Database URL:
jdbc:oracle:thin:@<host>:<port>:<SID>
-
Alternate database URL:
jdbc:oracle:thin:@<host>:<port>/<service_name>
-
Driver Name:
oracle.jdbc.OracleDriver
To accomplish this:
- Navigate to Configure > Admin > Security > Credentials.
- Click New.
- Select a Partition.
- Choose JDBC from the CredentialProtocol dropdown list.
- Enter a username and password in the Real User and Password fields.
- In the Endpoint field, enter
JDBC_Oracle12cLib_DB
. - Click Save & Close.
- Navigate to Configure > Automate > Scripting tools > Libraries.
- Choose Edit from the context menu of the Custom_Driver library. If the library does not exist, create it.
- On the JAR Files tab, click Add.
- Enter a name in the Name field and upload the JAR file from your system.
- Choose Save & Close.
- Navigate to Configure > Admin > Manage Connectors > Databases.
- Click New.
- Select a Partition.
- Enter
JDBC_Oracle12cLib_DB
in the Name field. - Select Custom_Driver from the Library dropdown list.
- Enter
oracle.jdbc.OracleDriver
in the Jdbc Driver Class Name field. - Select Jdbc Url > Advanced and fill
jdbc:oracle:thin:@ora12.example.com:1521/orcl
into the field. - Select an option from the Connection User dropdown list.
- Click Save & Close.
- Navigate to Configure > Control > Job Servers.
- Click New.
- Select Manual Setup and choose Next.
- Select a Partition.
- Enter JDBC_Oracle12cLib_ProcessServer in the Name field.
- On the Services tab, click
and select JDBCService.
- On the Definition Types tab, click
and select JDBC.
- Click Save & Close.
- Navigate to Configure > Automate > Scripting tools > Shell.
- Paste the following code into the Shell script field and click Run command.
Copy
{
Partition p = jcsSession.getPartitionByName("Example");
Database db = jcsSession.getDatabaseByName(p, "JDBC_Oracle12c_DB");
ProcessServer ps = jcsSession.getProcessServerByName(p, "JDBC_Oracle12c_ProcessServer");
ObjectReference objRef = ps.createObjectReference(db);
objRef.setName(Database.OBJECT_REFERENCE_NAME_JDBC_PROCESSSERVER);
jcsSession.persist();
}