Before You Begin
This 15-minute tutorial shows you how to integrate two Oracle Cloud services, Oracle Application Container Cloud Service and Oracle Database Cloud Service, by using a Java Platform, Enterprise Edition (Java EE) application.
Background
Oracle Application Container Cloud Service provides a lightweight infrastructure so that you can run Java EE, Java Platform, Standard Edition (Java SE), PHP, Python, Node.js, and Ruby applications in Oracle Cloud. To develop more robust applications, you can integrate this cloud service with other Oracle services (for example, Oracle Database Cloud Service).
This tutorial provides source code for connecting a Java EE sample web application to Oracle Database Cloud Service by using a Java Database Connectivity (JDBC) data source. The application implements create, read, update, and delete operations for the EMPLOYEE
table in the database.
What Do You Need?
- Access to an instance of Oracle Application Container Cloud Service
- An instance and credentials (user, password, and SSH private key) for Oracle Database Cloud Service (See Creating a Quickstart Instance in Database Cloud Service.)
- Oracle SQL Developer
- The Employees application: employees-app-dbcs.zip
Set Up the Database
- Open Oracle SQL Developer.
- Click the View menu and select SSH.
- Right-click SSH Hosts and click New SSH Host.
- In the New SSH Host dialog box,
enter or select the
following
values
and click OK:
- Name:
DBCS
- Host: The public IP address of your Oracle Database Cloud Service instance
- Username:
opc
- Use key file (After you select this check box, click Browse, and select the private key file.)
- Add a Local Port Forward (Select this check box.)
- Name:
Local
- Host:
localhost
- Port:
1521
- Use
specific local
port:
1523
Description of the illustration new_ssh_hosts.png - Name:
- Right-click the DBCS host connection and select Connect.
- If it's required, enter the passphrase.
- Right-click Connections and select New Connection.
-
In the New
/ Select
Database
Connection
dialog box,
enter or select the following values
and
click Test:
- Connection Name: Your connection name
- Username: Your database user name
- Password: Your database password
- Connection Type: SSH
- Role: default
- Port forward: Local (DBCS)
- Service
name:
PDB1.<your-identity-domain>.oraclecloud.internal
Note: Keep the default values for the rest of the fields.
- Click Save and then Connect.
- Right-click the connection and select Open SQL worksheet.
-
To
create the
EMPLOYEE
table and theEMPLOYEE_SEQ
sequence, copy the following script into the SQL worksheet:CREATE TABLE EMPLOYEE ( ID INTEGER NOT NULL, FIRSTNAME VARCHAR(255), LASTNAME VARCHAR(255), EMAIL VARCHAR(255), BIRTHDATE VARCHAR(10), TITLE VARCHAR(255), DEPARTMENT VARCHAR(255), PRIMARY KEY (ID) ); CREATE SEQUENCE EMPLOYEE_SEQ START WITH 100 INCREMENT BY 1;
- Click Run
Script
and then click Commit
.
Deploy Your Application to Oracle Application Container Cloud Service
- Extract the contents of the
employees-app-dbcs.zip
file to your local system. - Open the Oracle Application Container Cloud Service console.
- In the Oracle Cloud My Services dashboard, click Action
and select Oracle Application Container Cloud Service.
- In the Create Application dialog box, in the Applications list view, click Create Application and select Java EE.
- In the Application section, enter
EmployeeApplication
for the name of your application and click Browse. - In the File Upload dialog box, select the
employees-app.war
from theemployees-app-dbcs/target
directory and click Open. - If your account has access to Oracle Cloud Infrastructure regions, in the Region field select the same region that you used to create your Oracle Database Cloud Service instance.
- Keep the default values in the Instances and Memory fields and click Create.
Add the Service Binding and the JNDI Name
- After the application is created, on the Applications tab, click EmployeeApplication.
- Click the Deployments tab. In the Service Binding section, click Add.
- In the Add Service Binding dialog box, enter or select the following values and click Save:
- Service Type: Oracle Database Cloud Service
- Service Name: Your service name
- Username: Your database user name
- Password: Your password
- In the Oracle Database Cloud Service binding, click Add
.
- In the Add Service Binding Property dialog box, select JNDI Name for Name, enter
jdbc/testds
for Value, and then click Save.
- In the Deployments dialog box, click Apply Edits.
Test the Application
- After the application restarts, click the URL for your application.
Description of the illustration employee_app_response.png - Click New Employee, enter values in the Name, Last name, Birthdate, Role, Department, and E-mail fields, and click Accept.
- Click the ID number, update the employee information, and click Accept.
- To delete the employee, click
.
Want to Learn More?
- Oracle Application Container Cloud Service: Get Started in the Oracle Help Center