Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Synchronizing Wireless Application Data Using DB2 Everyplace

Naveen Balani, Technical Analyst
Naveen Balani spends most of his time in designing, developing, and implementing J2EE-based products. You can reach Naveen at naveenbalani@rediffmail.com.
(An IBM developerWorks Master Author, Level 3)

Summary:  Using an application from a previous article, the author shows you how to synchronize data and applications between DB2 Everyplace mobile devices and DB2 on the server.

Date:  21 Nov 2002
Level:  Introductory

Activity:  5715 views
Comments:  

Introduction

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
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.

  1. Install DB2 Everyplace database engine and the Sync Client applications on the mobile client.
  2. Create the source (DB2) database and tables for synchronization on the server.
  3. Create synchronization objects, using the Mobile Devices Administration Center (MDAC).
  4. 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:

  1. Right click on the Palm Emulator, choose Install Application/Database > Other.
  2. . 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:

  1. At the Windows command prompt, enter db2cmd.
  2. 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.

Creating users

  1. Click on User > Create, as shown below:

    Figure 1: User > Create screen
    User > Create screen
  2. Enter the name of the mobile user -- in our case, Naveen -- then click on the Authentication tab.

    Figure 2: Authentication
    Authentication
  3. 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
    Password
  4. 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.

Creating groups

  1. From MDAC, click on Group>Create.
  2. Enter the name of the group. In our example, we use NaveenGrp.

    Figure 4: Create group
    XML error: The image is not displayed because the width is greater than the maximum of 580 pixels. Please decrease the image width.

  3. Click on the Users tab, then move the user Naveen from Available users to Selected users, then click OK.

    Figure 5: Selected users
    Selected users

We've now added Naveen to a group. Let's now create the subscription object.

Creating a subscription

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

  1. 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
    Defining the replication source
  2. 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

  1. Click Subscription, then select Create > Table subscription > JDBC subscription..

    Figure 7: Creating a subscription
    XML error: The image is not displayed because the width is greater than the maximum of 580 pixels. Please decrease the image width.

  2. 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
    Naming the subscription
  3. 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.)

  4. Click on the tabtab 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
    Select Local DB2 Source Database

Creating a mirror database

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:

  1. Click on the Mirror tab, and enter a user ID and password that has access to the DB2 database.
  2. Click tab next to Database URL, which brings up the select mirror database window.
  3. 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
    specify database name
  4. On the Select Mirror Database window, click Refresh, then select the MR_ADDRS database, as shown here:

    Figure 11: Select mirror database
    Select mirror database
  5. Now we must map the source table (DB2) with the DB2 Everyplace table. To do this:
    1. Click on Define Subscription on the Identification Tab.
    2. Click Add, which invokes the window shown here:

      Figure 12: Add table
      Add table
    3. Select ADMINISTRATOR.ADDRESS as 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.

    4. Click Add to add this information.
    5. Select Administrator.Address on the Define Subscription window and click Advanced.

      Figure 13: Advanced replication subscription
      XML 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.

    6. 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.

Creating a subscription set

  1. Click on the Subscription Sets section in MDAC.
  2. Select Create to create a new subscription set, which invokes the window shown below:

    Figure 14: Create subscription set
    Create subscription set
  3. Enter the subscription set name in the Name field of the Identification tab.
  4. Click on the Subscriptions Tab, and add AddressJDBC subscription to the selected subscriptions tab:

    Figure 15: Add AddressJDBC
    XML error: The image is not displayed because the width is greater than the maximum of 580 pixels. Please decrease the image width.

  5. Similarly, click on Groups tab and add the NaveenGrp to the Selected groups pane as shown below, then click OK.

    Figure 16: Add groups
    Add groups
  6. Enable synchronization for our user groups:
    1. Choose the Group section.
    2. Select NaveenGrp, click on it and select Edit, which invokes the window shown here:

      Figure 17: Edit group - NaveenGrp
      Edit Group - NaveenGrp
    3. 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

  1. Click on IBM Sync Application on the Palm Emulator, then click Options > settings.

    Figure 18: Palm emulator
    Palm Emulator

    The sync server comes built in with a WebSphere® environment that hosts the sync servlet for synchronization.

  2. Enter the Server IP 127.0.0.1 if you have installed the Sync Server on the local machine, or enter the remote IP address of the sync server.
  3. Enter 8080 as the port, which is the default port of the Sync Servlet.
  4. In the User ID section, enter Naveen.
  5. For the Password, let the value be Prompt.
  6. Click OK to make the changes effective.

    Figure 19: Emulator settings
    Emulator settings
  7. We must do one more thing to redirect all the requests using TCP/IP protocol:
    1. Click on the emulator, and select Settings> Properties.
    2. Check the Redirect NetLib calls to host TCP/IP option.

      Figure 20: Emulator properties
      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.

  1. 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."
  2. Open the Palm Emulator, then select SAB Application to open the Address Book application as shown below.

    Figure 21: Address book app
    address book app
  3. Enter a new record and click on New. You should see a message that tells you the creation was successful.
  4. Click on Applications and select the IBM Sync Application, which opens the IBM Sync Application.
  5. Click on Synchronize Image, then enter the password associated with the user (Naveen) you had configured while creating the user in MDAC. Click OK.
  6. 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
Synchronization in progress
Synchronization successful
  1. 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.


Summary

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.


Resources

About the author

developerWorks Master author level 3

Naveen Balani spends most of his time in designing, developing, and implementing J2EE-based products. You can reach Naveen at naveenbalani@rediffmail.com.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=13495
ArticleTitle=Synchronizing Wireless Application Data Using DB2 Everyplace
publish-date=11212002
author1-email=naveenbalani@yahoo.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers