This article describes how you can synchronize data and applications between DB2® EveryplaceTM mobile devices and enterprise data sources using the DB2 Everyplace Sync Server and DB2 Everyplace Sync Client. We use DB2 Everyplace Enterprise Edition 8.1 for Windows® 2000 and Windows NT® for this article.
This article requires that you have already installed and configured DB2 Everyplace Enterprise Edition 8.1, DB2 Universal DatabaseTM Enterprise Edition v7.2 and deployed the Palm address book example as described in Creating a Mobile Application for Palm Devices Using DB2 Everyplace.
This article is intended to help you:
- Understand the synchronization process between mobile devices and DB2 Everyplace.
- Configure the synchronization process, create the replication store, and define subscriptions and access controls using Mobile Device Administrator Center.
- Test synchronization between the Sample Address Book Palm application and the DB2 data source.
Overview of the synchronization solution
The DB2 Everyplace solution for mobile data synchronization includes the DB2 Everyplace Sync Server, which acts as a client/server program that manages two-way data synchronization between a source relational database and a target database (a DB2 Everyplace database deployed on a mobile device). You install the Sync client on the mobile device. The Sync server acts as an intermediary between the synchronization client software on the mobile device and the DB2 UDB database or other JDBC database on the source server.
Data synchronization can be bi-directional or uni-directional. Data can be updated at the DB2 Everyplace mobile device or at the enterprise database. For example, users can download a subset of data from a DB2 database to a DB2 Everyplace database on the mobile device, view the data, make changes to the data, and then synchronize the changed data back to the source database. The DB2 Everyplace Sync Server also provides a mechanism for resolving conflicts.
The DB2 Everyplace Sync Server provides an administration tool called the Mobile Devices Administration Center (MDAC) that helps you manage and deliver synchronization services to groups of users with similar data synchronization needs.
The DB2 Everyplace Sync Client, which runs on mobile devices, is comprised of applications that work with the DB2 Everyplace Sync Server. It handles bi-directional synchronization of enterprise relational data with the DB2 Everyplace mobile database. The mobile device also manages operations related to file subscriptions for easy distribution of mobile applications to the device and can execute stored procedures stored on a DB2 database.
Figure 1 shows the interaction between the mobile client, the sync server, and the source database.
Figure 1. Interaction among the client, mid-tier, and source system

Configuring the DB2 Everyplace synchronization solution
Here is an overview of the configuration steps.
- Install DB2 Everyplace database engine and the Sync Client applications on the mobile client.
- Create the source (DB2) database and tables for synchronization on the server.
- Create synchronization objects, using the Mobile Devices Administration Center (MDAC).
- Set up the mobile device (in our case, the Palm Emulator) for synchronization.
Step 1: Install DB2 Everyplace and the Sync Client
If you read and followed the directions in my previous article, Creating Wireless Data using DB2 Everyplace, the DB2 Everyplace engine should already be installed on the PALM emulator. Now we can install the Sync Client on the Palm emulator, as follows:
- Right click on the Palm Emulator, choose Install Application/Database > Other.
- . In the browse window, go the directory where you had installed DB2 Everyplace (e.g;
c:\db2everyplace), and select the following files:
c:\db2everyplace\sync\Clients\PalmOS\dsyagent.prc c:\db2everyplace\sync\Clients\PalmOS\imsaconfig.prc c:\db2everyplace\sync\Clients\PalmOS\imsadb2e.prc c:\db2everyplace\sync\Clients\PalmOS\imsafile.prc c:\db2everyplace\sync\Clients\PalmOS\isynce.prc c:\db2everyplace\sync\Clients\PalmOS\isyncl.prc c:\db2everyplace\sync\Clients\PalmOS\isyncui.prc c:\db2everyplace\sync\Clients\PalmOS\PBSPkcs11.prc c:\db2everyplace\sync\Clients\PalmOS\wbxmllib.prc |
Now you have the Sync client on the Palm Emulator.
Step 2: Create the source (DB2) database and tables on the server
We need to create source tables on the server. These "source" tables are the tables on the DB2 server database with which we synchronize our wireless data. We'll be using the data from the address book that we created in the previous article. To create the source tables:
- At the Windows command prompt, enter
db2cmd. - Create the required database and tables, by entering the following statements:
db2 create database address db2 connect to address db2 CREATE TABLE Address (FirstName Char(30), LastName Char(30) not null primary key, Address char(30), Country char(30),PhoneNumber char(15)) db2 disconnect address |
This creates the address database and a table called address in that database.
Step 3: Create synchronization objects using MDAC
A synchronization object contains information about aspects of the synchronization process. There are six types of synchronization objects that can be configured for synchronization.
User: A user who uses the DB2 Everyplace Sync Server to synchronize data between a source (the enterprise system) and a target (the mobile device). You assign a user to a group to provide access to the subscriptions that are defined in the group's subscription sets.
Group: A group of users with similar mobile data synchronization needs. You define synchronization characteristics for each group, such as which applications the users in the group need to access to perform their jobs and what subsets of enterprise data they need to access.
Subscription: A specification for what information in a source database or server is to be replicated to a target database (the DB2 Everyplace database on the mobile device). You can create two types of subscriptions:
- File subscriptions for files stored at the source server.
- Table subscriptions in the source database using either DataPropagatorTM or JDBCTM subscriptions.
DataPropagator subscriptions provide users with access to data in source tables on a DB2 server, while JDBC subscriptions provide users with access to data in source tables on a data source with a JDBC interface, including Oracle®, DB2, Microsoft® SQL Server, Informix®, Sybase®, and Lotus® DominoTM.
Subscription set: A collection of subscriptions. To provide group members with access to the data and files defined in subscriptions, you collect the subscriptions together in a container called a subscription set, then assign this container object to the group. When users start the synchronization client software on the device, they choose which subscription set to synchronize. The menu of subscription sets that appears on the client is created from the list of subscription sets that is associated with the user's group.
Adapter: An adapter is used to synchronize and communicate with the Sync Server. A collection of adapters is included for synchronizing files, relational data (with DB2), relational data (with JDBC), and remote query and stored procedure functionality
Log: After you implement mobile data synchronization, you can monitor any synchronization problems using the error messages written to the error log.
For our synchronization process, let's create a user, a group, a subscription, and a subscription set. Use the MDAC to do this. All these synchronization objects are stored in the synchronization control database, DSYSCTLDB, which was created when you installed the DB2 Everyplace Sync Server.
- Click on User > Create, as shown below:
Figure 1: User > Create screen
- Enter the name of the mobile user -- in our case,
Naveen-- then click on the Authentication tab.
Figure 2: Authentication
- In the Authentication tab, enter a password. This password will be required as part of authentication process from the Mobile Client to the Sync Server.
Figure 3: Password
- Click OK to finish creating the User object.
Next we must add this user to a user group. A group is required to provide access to the subscriptions defined in the group's subscription sets.
- From MDAC, click on Group>Create.
- Enter the name of the group. In our example, we use
NaveenGrp.
Figure 4: Create groupXML error: The image is not displayed because the width is greater than the maximum of 580 pixels. Please decrease the image width. - Click on the Users tab, then move the user Naveen from Available users to Selected users, then click OK.
Figure 5: Selected users
We've now added Naveen to a group. Let's now create the subscription object.
Before creating our subscription, we must define our Address table as a replication source so that the DB2 Everyplace Sync Server knows which table to use for Synchronization.
This process is divided into the following steps:
Defining the replication source
Creating the JDBC subscription
Creating a mirror database
Defining the replication source
- From MDAC, select the Address table in the address database, then Define as Replication Source > DB2 Everyplace Sync Server.
Figure 6: Defining the replication source
- When the window appears, click on Run SQL now to make the database effective for replication. You will receive a message "Address Table available as a Replication Source".
Now we can create our JDBC subscription.
Creating the JDBC subscription
- Click Subscription, then select Create > Table subscription > JDBC subscription..
Figure 7: Creating a subscriptionXML error: The image is not displayed because the width is greater than the maximum of 580 pixels. Please decrease the image width. - Enter a name for the JDBC subscription. For our example, we are calling it
AddressJDBC.For encryption, select None, and leave the Adapter value as it is.
Figure 8: Naming the subscription
- In the Source tab, enter a user ID and password that has access to the DB2 database.
For Driver, select IBM DB2 UDB local, because we have installed DB2 on a local machine. (You would choose remote if DB2 UDB is located remotely.)
- Click on the
tab next to Database URL, which brings up the Select Local DB2 Source Database window, shown here. Select the ADDRESS database, then click OK.
Figure 9: Select local DB2 data source
Next we create and specify a mirror database for our application. The mirror database is required for staging operations to improve the throughput capacity of synchronization requests. Changes can be staged while other updates are taking place. The mirror database can also be used to resolve any conflicts that arise because of access from multiple clients
To create the mirror database:
- Click on the Mirror tab, and enter a user ID and password that has access to the DB2 database.
- Click
next to Database URL, which brings up the select mirror database window. - Click on Create, which invokes the DB2 database creation wizard shown below. Enter the database name (we use MR_ADDRS), then click Finish.
Figure 10: Specify database name
- On the Select Mirror Database window, click Refresh, then select the MR_ADDRS database, as shown here:
Figure 11: Select mirror database
- Now we must map the source table (DB2) with the DB2 Everyplace table. To do this:
- Click on Define Subscription on the Identification Tab.
- Click Add, which invokes the window shown here:
Figure 12: Add table
- Select
ADMINISTRATOR.ADDRESSas the source (DB2 UDB) table.By default, the target table is set to same as the source table. In our case, the target table maps to the DB2 Everyplace database table that is installed on the client side. Because our source tables and target table have the same names and have a one-to-one mapping it will work for us. If you have a different target table you need to specify it in the Target table field. If your target table doesn't have a schema, the schema name of the target default will be same as the source schema.
- Click Add to add this information.
- Select
Administrator.Addresson the Define Subscription window and click Advanced.
Figure 13: Advanced replication subscriptionXML error: The image is not displayed because the width is greater than the maximum of 580 pixels. Please decrease the image width.
This shows you the mapping of source table columns with target table columns, and it lets you indicate which fields you want to replicate. Because our column names are the same we don't need to do anything. Otherwise, we would have to select a particular field and use the Change option.
- Click OK to close the window.
Now we have finished describing our Subscription object, and it's time to group our subscriptions and users group into a subscription set.
- Click on the Subscription Sets section in MDAC.
- Select Create to create a new subscription set, which invokes the window shown below:
Figure 14: Create subscription set
- Enter the subscription set name in the Name field of the Identification tab.
- Click on the Subscriptions Tab, and add AddressJDBC subscription to the selected subscriptions tab:
Figure 15: Add AddressJDBCXML error: The image is not displayed because the width is greater than the maximum of 580 pixels. Please decrease the image width.
- Similarly, click on Groups tab and add the NaveenGrp to the Selected groups pane as shown below, then click OK.
Figure 16: Add groups
- Enable synchronization for our user groups:
- Choose the Group section.
- Select NaveenGrp, click on it and select Edit, which invokes the window shown here:
Figure 17: Edit group - NaveenGrp
- Select the Enable synchronization checkbox and click OK.
Our subscription sets are now configured.
Next, we move on to configure the Palm Emulator for synchronization.
Step 4: Configure the Palm Emulator for synchronization
- Click on IBM Sync Application on the Palm Emulator, then click Options > settings.
Figure 18: Palm emulator
The sync server comes built in with a WebSphere® environment that hosts the sync servlet for synchronization.
- Enter the Server IP
127.0.0.1if you have installed the Sync Server on the local machine, or enter the remote IP address of the sync server. - Enter
8080as the port, which is the default port of the Sync Servlet. - In the User ID section, enter
Naveen. - For the Password, let the value be Prompt.
- Click OK to make the changes effective.
Figure 19: Emulator settings
- We must do one more thing to redirect all the requests using TCP/IP protocol:
- Click on the emulator, and select Settings> Properties.
- Check the Redirect NetLib calls to host TCP/IP option.
Figure 20: Emulator properties
Now we can test the synchronization process.
Testing the synchronization process
Let's try synchronizing our sample address book application with the source DB2 database.
- Start the Sync Servlet by clicking Program Files- > DB2 Everyplace - > Start servlet for Sync Server. You will see some messages, followed by a message that says "Server Started on Http Port 8080."
- Open the Palm Emulator, then select SAB Application to open the Address Book application as shown below.
Figure 21: Address book app
- Enter a new record and click on New. You should see a message that tells you the creation was successful.
- Click on Applications and select the IBM Sync Application, which opens the IBM Sync Application.
- Click on Synchronize Image, then enter the password associated with the user (Naveen) you had configured while creating the user in MDAC. Click OK.
- The synchronization process starts, and you will see the following messages during synchronization, which indicate that synchronization is occurring for the NaveenSet Subscription set. Then you will see a "Synchronization succeeded" message.
Figure 22: Test synchronization
![]() |
![]() |
- Now let's be sure that the data is properly synchronized by opening up the DB2 Command prompt for the DB2 source database and entering:
DB2 Connect to Address DB2 Select * from Address |
You should see the same data that you entered in the SAB application.
We have used the features of DB2 Everyplace to create, deploy, and test our Sample Palm Application, and then we synchronized the data from that Palm application with a server DB2 database.
- Balani, Naveen. Creating Mobile Applications for Palm Devices Using DB2 Everyplace
- Mayer, Walter and and Joachim G. Stumpf. How to Set Up and Execute a Mobile Project Using DB2 Everyplace Project
Naveen Balani spends most of his time in designing, developing, and implementing J2EE-based products. You can reach Naveen at naveenbalani@rediffmail.com.






