# Using the Oracle Database Cloud - Database as a Service

Oracle Database Cloud - Database as a Service provides you the ability to deploy Oracle databases in the Cloud, with each database deployment containing a single Oracle database. You have access to the features and operations available with Oracle Database, but with Oracle providing the computing power, physical storage and (optionally) tooling to simplify routine database maintenance and management operations.

For more information about the Database as a Service, see `http://docs.oracle.com/cloud/latest/dbcs_dbaas/index.html`.

The Eclipse views that you use to work with Database As A service are:

- Oracle Cloud view, described in Using the Oracle Cloud View.

- Data Source Explorer, described in Using the Data Source Explorer.

In addition, you can examine and edit your database schema using the Schema Editor that displays tables and the relationships between them. For more information, see Using the RDB Schema Editor.

While you are connected, OEPE checks the status of database services every few minutes and if it finds a change it updates the list of services.

While you are connected, OEPE checks for changed services every few minutes and if it finds status changes it updates the list of services. So if you have made a change to Database as a Service connecting to your account in a browser, the change may not appear in OEPE immediately. You can refresh the view in Cloud View to see changes sooner.

There are a few tasks which you cannot perform in OEPE and have to perform after connecting to your account in a browser, for example, adding additional CPUs.

## Working with Database as a Service Connections

You can create a connection to Database as a Service from the Oracle Cloud view, described in How to Create an Oracle Cloud Connection. This displays the service nodes which are specific to the type of Oracle Cloud service the connection is to.

There are a number of tasks you can perform from the context menu of a Database as a Service node, as shown in Figure: Service node for database services

Service node for database services

The options are:

- Activate/Deactivate—Click Activate to log in to the database. For more information, see Activating the Database Service.

  Click Deactivate to disconnect from the database.

- Delete—Click to delete the database. You will be asked to confirm the action, and you can choose to run this in the background. When it is complete, the database is no longer listed in the Cloud View.

- Start—Click to start a stopped database.

- Stop—Click to stop a database.

- Restart—Click to stop and then start the database.

- Refresh

- Open in Browser—Click to open the Oracle Database Cloud Service page in the default browser.

- Open scrapbook—Click to open the database in the SQL Scrapbook.

- Properties—Click to open the Properties dialog for the database, which has three pages:

  - The Database Connection Filter Properties page (activated database only). This allows you to filter the objects you see under the database service node. For more information, see Filtering Database Objects.

  - The Database Connection Properties page (activated database only), which displays the database connection credentials.

  - The Oracle Database Cloud Service page, which gives details of the service name, status, public IP address, and so on.

### Activating the Database Service

You connect to the database service in the Cloud View by activating it:

1. In the Oracle Cloud view, right-click the database node and choose Activate, as shown in Figure: Activating Database as a Service.

   Activating Database as a Service

2. In the Oracle Database Credentials dialog, enter the following details:

   - User name—Enter the name of the database user you want to connect as.

   - Password—Enter the password associated with that database user.

   - Connect through SSH—(Optional) Select to connect using a Secure Shell client.

     For information about generating an SSH Key Pair, see "Generating a Secure Shell (SSH) Public/Private Key Pair" in Using Oracle Database Cloud - Database as a Service.

     Note: If the database listener port is open, you can bypass the SSH and connect to a cloud database directly. You can open the listener port using the compute service.

     - Private key file—the path to the SSH private key file that matches the public key that is associated with the deployment.

     - Passphrase—Enter the path to the SSH private key file.

## Working with the Database

When you activate the database connection, you can see the database objects in the schema, as shown in the Cloud View in Figure: Database objects in Cloud View.

Database objects in Cloud View

If you open the Data Source Explorer from Window > Show View > Other > Data Management > Data Source Explorer, you can see the same connection with the same database elements, as shown in Figure: Database objects in Data Source Explorer. For more information about the Data Source Explorer, see Using the Data Source Explorer.

Database objects in Data Source Explorer

In general, you can perform the same operations to an activated database connection in the Cloud View as in the Data Source Explorer, for example:

- Refresh

- From the schema node:

  - Edit—Opens the schema in the graphical Schema Editor.

  - New Table—Opens the Create Table dialog which allows you to define a new table.

  - Generate DDL—Opens the Generate DDL dialog where you select the model elements to include in the generated DDL script.

- From the Tables node:

  - Edit Schema—Opens the schema in the graphical Schema Editor.

  - New Table—Opens the schema in the graphical Schema Editor.

## Filtering Database Objects

You can filter the schemas you see in Cloud View and Data Source Explorer by editing the properties of an activated database service node.

The objects you choose to display by filtering are also shown in the Data Source Explorer.

1. In Cloud View, right-click the database service node and choose Properties.

2. In the Properties for Database dialog, choose Database Connection Filter Properties.

3. Choose how to define the filter:

   - Expression—Choose from the list of options and enter a string.

     For example, to just show the HR schema and its objects, choose Name contains the characters and enter `HR`.

   - Selection—Choose the schemas you want to display from the list of those available and, if necessary, reorder them.

   - Disable filter—Shows all the available schemas.

You can also filter schemas in Data Source Explorer using the connection properties.

## Editing Databases

You can edit schema objects in:

- Cloud View

- Data Source Explorer

- Schema Editor

You can perform similar tasks in the Cloud View and the Data Source Explorer, and the actions available depend on the database object node selected. For example:

- From the context menu of the schema node or the Tables node you can create a new table.

- From the context menu of a table, you can choose from a number of options, as shown in Figure: Context menu options for a table.

  Context menu options for a table

For more information about working with database objects, see Oracle Database Support.

Alternatively, you can work graphically with the schema in the Schema Editor, as shown in Figure: Database in Schema Editor. For more information about using the Schema Editor, see Using the RDB Schema Editor.

Database in Schema Editor

To open the schema in the schema editor:

- In either the Cloud View or the Data Source Explorer, right-click the schema or Tables node and choose Edit or Edit Schema.

Note: When you work in the Schema Editor, your changes are not saved back to Oracle Cloud until you click Save. Additionally, you should refresh Cloud View and Data Source Explorer so they reflect the current view in the Schema Editor.

## Administering Database as a Service

Database as a Service supports administration tasks such as creating a new instance or deleting an instance, and you can perform these tasks from OEPE.

### How to Create a New Database as a Service Instance

If you already have an Oracle Cloud account you can create a Database as a Service instance from the Cloud View in OEPE.

To create a new Database as a Service instance:

1. In Cloud View, right-click and choose New Database. This opens the Create Oracle Database Cloud Service Instance wizard.

   For information about completing this wizard, see "Creating a Database Deployment" in Using Oracle Database Cloud - Database as a Service.

2. Complete the Subscription page of the wizard, shown in Figure: Subscription page of Create Oracle Database Cloud Service Instance wizard, and click Next.

   Subscription page of Create Oracle Database Cloud Service Instance wizard

3. Complete the Service Details page of the wizard, shown in Figure: Oracle Cloud Storage Service Elements, and click Next.

   Service Details page of Create Oracle Database Cloud Service Instance wizard

4. Complete the Backup and Recovery page of the wizard, as shown in , and click Finish.

   Backup and Recovery page of Create Oracle Database Cloud Service Instance wizard

It can take up to an hour to provision the new service, and you can run the progress monitor in the background. Once the service instance is listed in the Cloud View without a status next to it you can activate it as described in Activating the Database Service.

### Deleting a Database as a Service Instance

When you no longer require a database deployment on Oracle Database Cloud - Database as a Service, you can delete it.

To delete a database deployment:

1. In Cloud View, location the database deployment you want to delete.

2. Right-click and choose Delete. You are prompted to confirm the deletion. Once deleted, the entry is removed from the list of database deployments displayed in Cloud View.

## Using Java with Database as a Service

OEPE helps you quickly incorporate an Database as a Service database into an application.

You can drag a schema from Cloud View or Data Source Explorer into a Java Project in the Project Explorer and OEPE automatically generates sample code, as shown in the example below. The sample code includes:

- User and password for the connection.

- The service name, `PDB1.demo001.oraclecloud.internal` in the example.

- The public IP address for the service, `192.0.2.1` in the example.

            public Connection createDatabaseConnection() throws SQLException {
                    final Properties properties = new Properties();
                    properties.setProperty("user", "hr");
                    properties.setProperty("password", "hr");
                    final Driver driver = new oracle.jdbc.OracleDriver();
                    final Connection connection = driver
                                    .connect("jdbc:oracle:thin:@//192.0.2.1:1521/PDB1.demo001.oraclecloud.internal", properties);
                    return connection;
            }

Before you begin, you must have a Java project in the Project Explorer.

You can drag the schema into an existing Java class, or you can drag the schema into an empty package in which case a new class is created containing the sample code.

To generate sample code from the database service:

- From either the Cloud View or the Data Source Explorer, drag the schema node to the Java project in the Project Explorer.