2 Managing the Client and Back-End Databases

The following sections describe how to create and manage the client database and how to connect to the back-end Oracle database:

2.1 Creating and Managing the Database for a Mobile Client

When you use the mobile client and mobile server to replicate data between the back-end Oracle database and your mobile device, a small database is created on your mobile device to contain the data—that is stored in tables known as snapshots. The snapshot tables are used to track the modifications that the client makes on the data, which is then replicated during the synchronization process to the back-end database. All of this activity is transparent to the client. Your application queries and modifies data using SQL as if interacting with any Oracle database.

The client database is automatically created on the first synchronization request. In addition, the data is replicated and updated with the data on the Oracle database automatically for you. See Section 2.3, "What is the Process for Setting Up a User for Synchronization?" in the Oracle Database Mobile Server Developer's Guide for techniques that can be used to create publication items on the mobile server, which then automatically creates snapshots on the client when you synchronize with the database.

2.2 Connecting to the Back-End Oracle Database

When you are connecting to the back-end Oracle database, use the JDBC driver. When connecting to the repository in the back-end Oracle database, provide a URL to locate the database. Use the Thin JDBC driver to connect to the back-end Oracle database. With the Thin JDBC driver, you can either provide the host, port and SID, the Oracle Net address or tnsnames entry.

The syntax for providing the host, port and SID is as follows:

jdbc:oracle:thin:@<hostname>:<port>:<sid> 

For example, the following JDBC URL for the thin JDBC driver connects to my-pc.us.oracle.com on port 1521 with SID of orcl:

jdbc:oracle:thin:@my-pc.us.oracle.com:1521:orcl 

The syntax for using an Oracle Net address or tnsnames entry is as follows:

 jdbc:oracle:thin:@oracle-net-address-or-tnsnames-entry
 

For example, the following JDBC URL for the thin JDBC driver connects to the MyDB tnsnames entry:

jdbc:oracle:thin:@MyDb 

Alternatively, you could provide the full Oracle Net address, as follows:

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
 (HOST=my-pc.us.oracle.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=mypc))) 

If the mobile server repository is installed in an Oracle RAC database, then provide the JDBC URL for an Oracle RAC database, which can have more than one address for multiple Oracle databases in the cluster. The following is the URL structure for an Oracle RAC database address:

jdbc:oracle:thin:@(DESCRIPTION=
 (ADDRESS_LIST=
   (ADDRESS=(PROTOCOL=TCP)(HOST=PRIMARY_NODE_HOSTNAME)(PORT=1521))
   (ADDRESS=(PROTOCOL=TCP)(HOST=SECONDARY_NODE_HOSTNAME)(PORT=1521))
 )
 (CONNECT_DATA=(SERVICE_NAME=DATABASE_SERVICENAME)))