Enterprise J2ME Developing Mobile Java Applications [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Enterprise J2ME Developing Mobile Java Applications [Electronic resources] - نسخه متنی

Michael Juntao Yuan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



13.3 IBM DB2 Everyplace


DB2e databases and IBM FastRecordStores (see Section 12.3) synchronize with backend DB2 Universal databases or any other JDBC data sources through the DB2e Sync server. In DB2e v8.1, multiple combinations of synchronization clients, transport mechanisms and backend data sources are supported through the adaptor architecture (Figure 13.4).


Figure 13.4. The adaptor architecture in DB2 synchronization engine.


The synchronization client on the mobile device can handle DB2e databases, native PIM lists and files.

The clientside synchronization engine communicates with the synchronization server via HTTP, WAP or Bluetooth. Both proprietary binary protocols and SyncML are supported.

The synchronization server supports the DB2 Universal Database, any JDBC database as well as Domino and Exchange servers.


We can start the Sync server from the Mobile Devices Administration Center in DB2e's server console. Using the administration center UI, we can create users and subscription sets, associate users with subscription sets, specify encryption levels, and define conflict resolution logic. On the client side, DB2e Sync runs natively on three mobile platforms: Palm OS, Windows CE, and Symbian OS. Using device-native GUIs, a mobile user can login to the Sync server, download the subscription sets, manage subscription sets, and synchronize mobile databases. For more information on how to configure and run the DB2e Sync server and client, please refer to DB2e documentation (see "Resources").


13.3.1 Access DB2e Sync Programmatically


The above synchronization process requires human interaction with a standalone client program. That is not always convenient. DB2e provides a set of J2ME APIs that allow users to access the DB2e Sync server programmatically. Those Java APIs are just JNI wrappers over DB2e's native Sync methods. Listing 13.3 illustrates the use of such APIs.

Listing 13.3. DB2e Sync client application



import com.ibm.mobileservices.isync.*;
import com.ibm.mobileservices.isync.db2e.jni.*;
// Get a synchronization provider
ISyncProvider provider = DB2eISyncProvider.getInstance();
// Connect to an IBM Sync server
// "host, port, userID, passwrd"
// specify parameters of
// the remote IBM Sync server.
ISyncService service = provider.createSyncService(host, port,
userID, passwrd);
// Specify a directory to sync into
ISyncConfigStore config = service.getConfigStore("path");
// Manage available subscription sets from
// the client
ISyncSubscriptionSet [] subsets = config.getSubscriptionSets();
for ( int i; i < subsets.length; i++ ) {
ISyncSubscriptionSet subset = subsets[i];
// Enable synchronization of all tables
subset.enable();
}
ISyncDriver syncer = config.getSyncDriver();
// Synchronize. There could be three return values
//
// ISync.RTN_SUCCEEDED: synchronization succeeded
// ISync.RTN_CANCELED: synchronization canceled
// ISync.RTN_FAILED: synchronization failed
int rc = syncer.sync();
// Detailed results for each subscription set
//
// ssArr[i].getStatus() returns:
// ISync.STATUS_READY, ISync.STATUS_COMPLETED,
// STATUS_CANCELED or ISync.STATUS_FAILED
ISyncSubscriptionSet ssArr[] = config.getSubscriptionSets();
for (int i=0; i < ssArr.length; i++ ) {
System.out.print ("Subscription Set: " + ssArr[i].getName() +
" Status: " + ssArr[i].getStatus());
// Close resources
syncer.close();
config.close();
service.close();


13.3.2 Sync with MIDP FastRecordStore


As we had discussed in Chapter 12, Section 12.3, DB2e supports a mechanism to synchronize backend databases with its proprietary FastRecordStores on MIDP devices. The following code snippet (Listing 13.4) illustrates the synchronization process. If this is the first time we synchronize, a new FastRecordStore with the same table name will be created and populated with data rows from the table.

Listing 13.4. Using DB2e Sync to synchronize MIDP FastRecordStore



import com.ibm.mobileservices.isync.*;
import com.ibm.mobileservices.isync.midp.*;
ISyncProvider provider = MIDPISyncProvider.getInstance();
ISyncService service = provider.createSyncService(host, port,
user, password);
ISyncConfigStore config = service.getConfigStore(null);
ISyncDriver syncer = config.getSyncDriver();
int rc = syncer.sync();
syncer.close();
config.close();
service.close();


/ 204