5 Synchronization Utilities for Java Sync Client

The following sections provide information on synchronization utilities for java sync client:

5.1 OSync Utility

The OSync utility is used to do synchronization for Java Sync client. The usage is given as follows:

Table 5-1 Usage of OSync Utility

Parameter Description

user, pwd, url

Username, password, server URL

-f

Use files to store temporary sync payload

-ns

Do not save sync metadata files before sync

-sp

Save sync password in encrypted form in sync metadata files

-r

Enable resume

-ssl

Use SSL over HTTP

-sel pub

Sync with selective publication

-nnp

Do not download new publications

-fr

Force complete refresh

-np password

New password

-hp

High priority

-so

Send only one-way sync

-cancel stage percent

Sync and cancel at stage and percent, specify stage and percent with numbers, valid numbers for stage are 1 - 4, valid numbers for percent are 1 - 99.

-param par1=val1 par2=val2

Set parameters in ose.ini before sync, refer to oracle.opensync.tools.SetParam for valid parameters in ose.ini.


The OSync utility is supported for both the Java SE client and the Java ME (OJEC) client. For Java SE Berkeley DB and SQLite clients, OSync will do synchronization with the Ch-Werner JDBC Driver by default. However, you can specify which JDBC driver to use during synchronization by using the OSync command below. For Java SE Java DB client the Apache Derby Embedded JDBC driver is used and you cannot specify an alternate. For Java ME (OJEC) client the Ch-Werner JDBC driver is used and you cannot specify an alternate.

The following command is used to sync with the Berkeley DB database and Ch-Werner JDBC driver:

java -Djava.library.path=<path to BDB native and jdbc jni libraries> -cp .:osync_se_bdb.jar:jdbc.jar oracle.opensync.tools.OSync <USER_NAME> <PASSWORD> <SERVER_ URL: MobileServerIp:MobileServerPort> -param OSE.FILES=YES

The following command is used to sync with the SQLite database and Zentus JDBC driver:

java -cp .:osync_se_sqlite.jar:sqlitejdbc-v053.jar oracle.opensync.tools.OSync <USER_NAME> <PASSWORD> <SERVER_URL: MobileServerIp:MobileServerPort> -param OSE.FILES=YES -param JDBC.DRIVER=org.sqlite.JDBC -param JDBC.URL_PFX=jdbc:sqlite:

The following command is used to sync with the Apache Derby Embedded JDBC Driver and Java DB database:

java -cp .:osync_se_javadb.jar:derby.jar oracle.opensync.tools.OSync <USER_NAME> <PASSWORD> <SERVER_URL: e.g. MobileServerIp:MobileServerPort> -param OSE.FILES=YES

Another method to specify which JDBC driver to use during synchronization is to create an ose.ini file manually in the same directory as Java sync engine archive file and add the parameters below to it before you invoke OSync utility.

To sync with Ch-Werner JDBC driver, the corresponding parameters should be:

  • JDBC.DRIVER=SQLite.JDBCDriver

  • JDBC.URL_PFX=jdbc:sqlite:/

To sync with Zentus JDBC driver, the corresponding parameters should be:

  • JDBC.DRIVER=org.sqlite.JDBC

  • JDBC.URL_PFX=jdbc:sqlite:

Note:

Parameters JDBC.DRIVER and JDBC.URL_PFX are only supported by Java SE Berkeley DB and Java SE SQLite clients.

The difference between the ME client and SE client is that you must specify parameter OSE.FILES=YES for the ME client to do the synchronization, either in the OSync command line, or in the ose.ini configuration file.

If your Mobile Server URL starts with "https", you must specify parameter NETWORK.DISABLE_SSL_CHECK = YES, either in the OSync command line, or in the ose.ini configuration file.

For more information, refer to javadoc of class oracle.opensync.tools.OSync.

5.2 SetParam Utility

SetParam utility is used to create and edit ose.ini, which is in the same directory as Java sync engine archive file. The supported parameters in ose.ini are given in the following table:

Table 5-2 Usage of SetParam Utility

Parameter Description

BDB.LARGE_RECORD_OPT=<value>

Any record larger than <value> will be stored in a new format that improves read and write performance for large records.

BDB.STREAMING=YES|NO

Set this parameter to YES to use the Ch-Werner Java wrapper with the Pure Java SE clients, OJEC client, or Berkeley DB Android client.

Set this parameter to NO to use the Ch-Werner JDBC driver with the Pure Java SE clients, OJEC client, or Berkeley DB Android client.

BGSYNC.DISABLE=YES|NO

Enable/Disable Sync Agent

OSE.RESUME=YES|NO

Use resume or not

OSE.FILES=YES|NO

Use files or not to store temporary sync payload

OSE.ENCRYPTDB=YES|NO

Encrypt the client database (YES), otherwise do not encrypt it (NO). The default is NO. This applies to native and Pure Java clients using Berkeley DB.

SQLITE.LIMIT_CONNECTIONS=YES|NO

Limit number of database connections during sync to 2 (queue-based mode) or 1 (state-based mode). Currently required for Blackberry client where OS limits number of database connections.

SQLITE.QUEUES=YES|NO

Use queue-based mode (YES) or state-based mode (NO) for Berkeley DB and SQLite.

SQLITE.DATA_DIRECTORY=<path name>

Root of the client database directory for Berkeley DB and SQLite (for example, <mobileclient>/bdb/data for Berkeley DB, or <mobileclient>/sqlite_db for SQLite)

JDBC.DRIVER=<JDBC driver>

JDBC driver class name for Berkeley DB and SQLite (for example, org.sqlite.JDBC for Zentus JDBC driver, and SQLite.JDBCDriver for Ch-Werner JDBC driver)

JDBC.URL_PFX=<JDBC URL prefix>

JDBC URL prefix for Berkeley DB and SQLite (for example, jdbc:sqlite: for Zentus JDBC driver, and jdbc:sqlite:/ for Ch-Werner JDBC driver)

JAVADB.DATA_DIRECTORY=<path name>

Root of the Java DB client database directory. Default is <mobileclient>/javadb_home.

JAVADB.QUEUES=YES|NO

Use queue-based mode (YES) or state-based mode (NO) for Java DB.

JAVADB.SHUTDOWN_ON_CLOSE=YES|NO

Whether or not to shut down the Java DB engine when sync engine is shut down. Default value is NO.

BGSYNC.NET_WAIT_TIMEOUT=<integer value>

Time interval in ms to wait to check network status in syncagent in absence of network notifications. Default is 600000 ms or 10 minutes.

NETWORK.DISABLE_SSL_CHECK=YES|NO

Disable SSL Certificate check on the client. Needed if server uses self-signed certificates.


Usage:

java -cp .:<Java SE archive> oracle.opensync.tools.SetParam parameter1=<value1> parameter2=<value2>

Example:

java -cp .:osync_se_bdb.jar oracle.opensync.tools.SetParam OSE.FILES=NOjava -cp .:osync_se_sqlite.jar oracle.opensync.tools.SetParam OSE.FILES=NOjava -cp .:osync_se_javadb.jar oracle.opensync.tools.SetParam OSE.FILES=NO

You can invoke the utility in command line or call the included class methods in oracle.opensync.tools.SetParam from your own classes to programmatically set the parameters in ose.ini before the call to sync.

For more information, refer to javadoc of class oracle.opensync.tools.SetParam.

5.3 SyncConsole Utility

You can use SyncConsole utility to invoke a synchronization, set parameters in ose.ini and control syncagent for Java Sync client.

Usage:

  • To start it with Berkeley DB database and Ch-Werner JDBC driver:

    java -Djava.library.path=<path to BDB native and jdbc jni libraries> -cp .:osync_se_bdb.jar:jdbc.jar oracle.opensync.tools.SyncConsole 
    
  • To start it with SQLite database and Zentus JDBC driver:

    java -cp .:osync_se_sqlite.jar:sqlitejdbc-v053.jar oracle.opensync.tools.SyncConsole 
    
  • To start it with Java DB database and Apache Derby Embedded JDBC driver:

    java -cp .:osync_se_javadb.jar:derby.jar oracle.opensync.tools.SyncConsole
    

You can input commands once you start SyncConsole. The supported commands are as follows:

Table 5-3 Usage of SyncConsole Utility

Command Description

sync

Invokes oracle.opensync.tools.OSync to do a synchronization. You can refer to Section 5.1, "OSync Utility" for valid parameters for OSync.

status

Reports sync agent status.

start

Start Syncagent. The command will wait for syncagent to be started unless -nw or -nowait option is specified.

stop

Stop Syncagent. The command will wait for syncagent to be stopped unless -nw or -nowait option is specified.

pause

Pause Syncagent. The command will wait for syncagent to be paused unless -nw or -nowait option is specified.

resume

Resume Syncagent. The command will wait for syncagent to be resumed unless -nw or -nowait option is specified.

enable

Enables Sync Agent

disable

Disables Sync Agent. It would stop Sync Agent first and then Disable it. If you specify -nw or -nowait, it will disable immediately.

message

Invoking this command first time will add message handler to syncagent to dump syncagent messages into file named "SyncConsoleMsg.txt" in the working directory. Invoking this command second time will remove this message handler so that writing of syncagent messages will be stopped.

msg

The same as command "message".

setparam

Invokes oracle.opensync.tools.SetParam to set parameters in ose.ini. You can refer to Section 5.2, "SetParam Utility" for valid parameters for SetParam.

q

Exit SyncConsole process.

exit

The same as command "q".

quit

The same as command "q".


For example:

Sync Console>sync john john server_url