The following sections describe the APIs available to start synchronization programmatically within your application, whether the application is C, C++, or Java:
You can initiate and monitor synchronization from a C or C++ client application. The synchronization methods for the C/C++ interface are contained in ocapi.h
and ocapi.dll
, which are located in the <ORACLE_HOME
>\Mobile\bin
directory.
A C++ example is provided in the <ORACLE_HOME
>\Mobile\Sdk\Samples\sync\msync\src
directory. The source code is contained in SimpleSync.cpp
. The executable—SimpleSync.exe
—is in the <ORACLE_HOME
>\Mobile\Sdk\Samples\sync\msync\bin
directory.
The functions available for setting up and initiating the synchronization are as follows:
Section 4.1.2, "Initializing the Environment With ocSessionInit"
Section 4.1.4, "Retrieving Publication Information With ocGetPublication"
Section 4.1.6, "Manage What Tables Are Synchronized With ocSetTableSyncFlag"
Section 4.1.8, "Start the Synchronization With the ocDoSynchronize Method"
Section 4.1.9, "Clear the Synchronization Environment Using ocSessionTerm"
Section 4.1.10, "Retrieve Synchronization Error Message with ocGetLastError"
The Synchronization API does not run under the eshell.exe.
For starting synchronization, the application performs the following:
Create, memset, and initialize the ocEnv
structure.
Set any optional fields in the ocEnv
structure before you execute the ocSessionInit method. Additionally, you can set proxy information in the ocSetSyncOption
method, or optionally specify synchronization type for each table with the ocSetTableSyncFlag
function.
Invoke the ocSessionInit()
method.
If you want to update the ocEnv
structure after the ocSessionInit, you can perform the ocSaveUserInfo
method.
Invoke the ocDoSynchronize()
method, which returns after the synchronization completes, an error occurs, or the user interrupts the process. While executing, the ocDoSynchronize
function invokes any callback function set in the ocEnv.fnProgress
field. The callback function must not call any blocking functions, as this process is not reentrant or threaded.
Once synchronization completes, then invoke the ocSessionTerm()
method to clear the ocEnv
data structure.
If synchronization failed, then use the ocGetLastError
function to retrieve the error message.
For an example, see the msync.cpp
sample code.
The ocSessionInit
function initializes the synchronization environment—which is contained in the ocEnv
structure or was created with ocSaveUserInfo
. For more information, see Section 4.1.5, "Managing User Settings With ocSaveUserInfo".
Note:
Every time you invoke theocSessionInit
function, you must also clean up with ocSessionTerm
. These functions should always be called in pairs. See Section 4.1.9, "Clear the Synchronization Environment Using ocSessionTerm" for more information.int ocSessionInit( ocEnv env );
Table 4-1 lists the ocSessioninit
parameter and its description.
Table 4-1 ocSessionInit Parameters
Name | Description |
---|---|
|
An |
This call initializes the ocEnv
structure—which holds context information for the synchronization engine—and restores any user settings that were saved in the last ocSaveUserInfo
call, such as username and password (See Section 4.1.5, "Managing User Settings With ocSaveUserInfo"). An ocEnv
structure is passed as the input parameter. Perform the following to prepare the ocEnv
variable:
Create the ocEnv
by allocating a variable the size of ocEnv
.
Memset the ocEnv
variable before invoking the ocSessionInit
function. If you do not perform a memset
on the ocEnv
variable, then the ocSessionInit
function will not perform correctly.
Set all required fields in the ocEnv
structure before passing it to ocSessionInit
. If the caller wants to overwrite user preference information after the ocSessionInit()
call, it can be done by calling ocSaveUserInfo
.
For a full description of ocEnv
, see Section 4.1.3.1, "ocEnv Data Structure".
The following example allocates a new ocEnv
, which is then passed into the ocSessionInit
call.
env = new ocEnv; // Reset ocenv memset( env, 0, sizeof(ocEnv) ); // init OCAPI ocError rc = ocSessionInit(env);
Two data structures—ocEnv Data Structure and ocTransportEnv Data Structure—are used for certain functions in the Mobile Sync API.
The ocEnv
data structure holds internal memory buffers and state information. Before using this structure, the application initializes it by passing it to the ocSessionInit
method.
Table 4-2 lists the field name, type, usage, and corresponding description of the ocEnv
structure parameters.
Required—If the usage is required, then you either set before calling the ocSessionInit
function or you have saved these parameters previously with the ocSaveUserInfo
function.
Optional—If the usage is optional, then optionally set after calling the ocSessionInit
function and before the ocDoSynchronize
function.
Read Only.
Table 4-2 ocEnv Structure Field Parameters
Field | Type | Usage | Description |
---|---|---|---|
username |
|
Required. |
Name of the user to authenticate. This name is limited to 28 characters, because of other parts of the product. |
password |
|
Required. |
User password (clear text). This name is limited to 28 characters, because of other parts of the product. |
trType |
Enum |
Required. |
If set to 0 ( |
newPassword |
|
Optional. |
If first character of this string is not null—in otherwords (char) 0—this string is sent to the server to change the user password; the password change is effective on the next synchronization session. |
savePassword |
Short |
Optional. |
If set to 1, the password is saved locally and is loaded the next time |
appRoot |
|
Optional. |
Directory to where the application will be copied. If first character is null, then it uses the default directory. |
priority |
Short |
Optional. |
0= OFF (default) 1= ON; Only high priority table or rows are synchronized when turned on. |
secure |
Short |
Optional. |
If set to 0, then AES is used on the transport. If set to |
syncDirection |
Enum |
Optional. |
If set to 0 ( |
exError |
ocError |
Read-only. |
Extended error code - either OS or OKAPI error code. |
transportEnv |
ocTransportEnv |
Transport buffer. See Section 4.1.3.2, "ocTransportEnv Data Structure". |
|
progressProc |
fnProgress |
Optional. |
If not null, points to the callback for progress listening. See Section 4.1.8.1, "See Progress of Synchronization with Progress Listening". |
totalSendDataLen |
Long |
Reserved |
|
totalRecieveDataLen |
Long |
Reserved |
|
userContext |
Void* |
Optional. |
Can be set to anything by the caller for context information (such as progress dialog handle, renderer object pointer, and so on. |
ocContext |
Void* |
Reserved. |
|
logged |
Short |
Reserved. |
|
bufferSize |
Long |
Reserved (for Wireless/Nettech only). |
|
pushOnly |
Short |
Optional. |
If set to 1, then only push changes to the server. |
syncApps |
Short |
Optional. |
Set to 1 (by default), performs application deployment. If set to 0, then no applications will be received from the server. |
syncNewPublications |
Short |
Optional. |
If set to 1 (default), receives any new publication created from the server since last synchronization. If set to 0, only synchronizes existing publications (useful for slow transports like wireless). |
clientDbMode |
Enum |
Optional. |
If set to |
syncTimeLog |
Short |
Optional. |
If set to 1, log sync start time is recorded in the |
updateLog |
Short |
Optional. |
Debug only. If set to 1, logs server-side insert and update row information to the publication odb. |
options |
Short |
Optional. |
Debug only. A bitset of the following flags:
|
cancel |
Short |
Caller can set to 1 on next operation. |
The environment structure contains fields that the caller can update to change the way Mobile Sync module works. The following example demonstrates how to set the fields within the ocEnv
structure.
typedef struct ocEnv_s { // User info char username[MAX_USERNAME]; // Mobile Sync Client id, limited to 28 characters char password[MAX_USERNAME]; // Mobile Sync Client password for // authentication during sync, limited to 28 chars char newPassword[MAX_USERNAME]; // resetting Mobile Sync Client password // on server side if this field is not blank short savePassword; // if set to 1, save password char appRoot[MAX_PATHNAME]; // dir path on client device for deploying files short priority; // High priority table only or not short secure; // if set to 1, data encrypted over the wire enum { OC_SENDRECEIVE = 0, // full step of synchronize OC_SENDONLY, // send phase only OC_RECEIVEONLY, // receive phase only OC_SENDTOFILE, // send into local file | pdb OC_RECEIVEFROMFILE // receive from local file | pdb }syncDirection; // synchronize direction enum { OC_BUILDIN_HTTP = 0, // Use build-in HTTP transport method OC_USER_METHOD // Use user defined transport method }trType; // type of transport ocError exError; // extra error code ocTransportEnv transportEnv; // transport control information // GUI related function entry progressProc fnProgress; // callback to track progress; this is optional // Values used for Progress Bar. If 0, progress bar won't show. long totalSendDataLen; // set by Mobile Sync API informing transport total number // of bytes to send; set before the first fnSend() is called long totalReceiveDataLen; // to be set by transport informing Mobile Sync API // total number of bytes to receive; // should be set at first fnReceive() call. void* userContext; // user defined context void* ocContext; // internal use only short logged; // internal use only long bufferSize; // send/receive buffer size, default is 0 short pushOnly; // Push only flag short syncApps; // Application deployment flag short cancel; // cancel } ocEnv;
You can configure the HTTP URL, proxy, proxy port number and other HTTP-specific transport definitions in the ocTrHttp
structure. This structure is an HTTP public structure defined in octrhttp.h
.
You access the ocTrHttp
structure from within the ocTransportEnv
data structure, which is provided as part of the ocEnv
data structure. The following demonstrates the fields within the ocTransportEnv
structure:
typedef struct ocTransportEnv_s { void* ocTrInfo; // transport internal context
The ocTrInfo
is a pointer that points to the HTTP parameters in the ocTrHttp
structure. The following code example retrieves the ocTrInfo
pointer to the HTTP parameters and then modifies the URL, proxy, and proxy port number to the input arguments:
ocTrHttp* http_params = (ocTrHttp*)(env->transportEnv.ocTrInfo); // set server_name strcpy(http_params->url, argv[3]); // set proxy strcpy(http_params->proxy, argv[4]); // set proxy port http_params->proxyPort = atoi(argv[5])
This function gets the publication name on the client from the Web-to-Go application name. The Web-to-Go user knows only the application name, which happens when the Packaging Wizard is used to package an application before publishing it. If the Web-to-Go application needs the publication name in order to interact with the database, then this function is used to retrieve that name, given the application name.
ocError ocGetPublication(ocEnv* env, const char* application_name, char* buf, int buf_len);
The parameters for the ocGetPublication
function are listed in Table 4-3 below.
Table 4-3 ocGetPublication Parameters
Name | Description |
---|---|
|
Pointer to an |
|
The name of the application. |
|
The buffer where the publication name is returned. |
|
The buffer length, which must be at least 32 bytes. |
Return value of 0 indicates that the function has been executed successfully. Any other value is an error code.
The following code example demonstrates how to get the publication name.
void sync() { ocEnv env; int rc; // Clean up ocenv memset(&env 0, sizeof(env) ); // init OCAPI rc = ocSessionInit(&env); strcpy(env.username, "john"); strcpy(env.password, "john"); // We use transportEnv as HTTP paramters ocTrHttp* http_params = (ocTrHttp*)(env.transportEnv.ocTrInfo); strcpy(http_params->url, "your_host"); // Do not sync webtogo applicaton "Sample3" char buf[32]; rc = ocGetPublication(&env, "Sample3", buf, sizeof(buf)); rc = ocSetTableSyncFlag(&env, buf, NULL, 0); // call sync rc = ocDoSynchronize(&env); if (rc < 0) fprintf(stderr, "ocDoSynchronize failed with %d:%d\n", rc, env.exError); else printf("Sync compeleted\n"); // close OCAPI session rc = ocSessionTerm(&env); return 0; }
Saves user settings for the ocEnv
structure. These settings can be used for the current session or used by the ocSessionInit
function to initialize the environment when next invoked.
int ocSaveUserInfo( ocEnv *env );
Table 4-4 lists the ocSaveUserInfo
parameter and its description.
Table 4-4 ocSaveUserInfo Parameters
Name | Description |
---|---|
|
Pointer to the synchronization environment. |
This saves or overwrites the user settings into a file or database on the client side. The following information provided in the environment structure is saved:
Note:
See Section 4.1.3.1, "ocEnv Data Structure" or Section 4.1.3.2, "ocTransportEnv Data Structure" for more information.username
password
savePassword
newPassword
priority
secure
pushOnly
syncApps
syncNewPublications
If you use the HTTP default transport set in the ocTransportEnv
structure, then the following is also saved:
url
useProxy
proxy
proxyPort
For more information on how to use these fields, see Section 4.1.3, "Managing the C/C++ Data Structures".
Update the table flags for selective sync. Call this for each table to specify whether it should be synchronized(1) or not (0) for the next session. Selective sync only works if you have first performed at least one synchronization for the client. Then, set the flag so that on the next synchronize—that is, before the next invocation of the ocDoSynchronize
method—a selective sync occurs.
Note:
Automatic synchronization is based on a different model than manual synchronization. Automatic synchronization operates on a transactional basis. Thus, the selective sync option is not supported when you use automatic synchronization for a publication, since we are no longer concerned with synchronization of only a subset of data.The default sync_flag
setting for ocSetTableSyncFlag
is TRUE (1) for all the tables; that is, all tables are flagged to be synchronized. If you want to selectively synchronize specific tables, you must first disable the default setting for all tables and then enable the synchronization for only the specific tables that you want to synchronize.
ocSetTableSyncFlag(ocEnv *env, const char* publication_name, const char* table_name, short sync_flag)
Table 4-5 lists the name and description of parameters for the ocSetTableSyncFlag
function.
Table 4-5 ocSetTableSyncFlag Parameters
Name | Description |
---|---|
|
Pointer to the synchronization environment. |
|
The name of the publication which is being synchronized. If the value for the |
|
This is the name of the snapshot. It is the same as the name of the |
|
If the |
This function allows client applications to select the way specific tables are synchronized.
Set sync_flag
for each table or each publication. If sync_flag
= 0, the table is not synchronized.
To synchronize specific tables only, you must perform the following steps:
Disable the default setting, which is set to 1 (TRUE) for all the tables.
Example:
ocSetTableSyncFlag(&env, <publication_name>,null,0)
Where <publication_name>
must be replaced by the actual name of your publication, and where the value null
is specified to mean all the tables for that publication without exception.
Enable the selective sync for specific tables.
Example:
ocSetTableSyncFlag(&env, <publication_name>,<table_name>,1)
If you are using a firewall and need to configure proxy information, perform the following before you execute the ocDoSynchronize
method:
Configure the proxy URL, IP address and/or port number through the ocSaveUserInfo
function. See Section 4.1.5, "Managing User Settings With ocSaveUserInfo" for more information.
If required, configure the proxy username and password. To configure the proxy username and password, use the ocSetSyncOption
and provide the following:
ocSetSyncOption( env, "HTTPUSER=<username>;HTTPPASS=<password>");
Note:
The username and password are limited to 28 characters.Where the ocSetSyncOption
syntax is as follows:
int ocSetSyncOption(ocEnv *env, const char *str);
You can set one or more name/value pairs searated by a semi-colon in the string. The previous example shows the HTTPUSER
and HTTPPASS
name/value pairs. You can also set the URL string as follows: URL=www.myhost.com
.
Starts the synchronization process.
int ocDoSynchronize( ocEnv *env );
Table 4-6 lists the name and description of the ocDoSynchronize
parameter.
Table 4-6 ocDoSynchronize Parameters
Name | Description |
---|---|
|
Pointer to the synchronization environment. |
This starts the synchronization cycle. A round trip synchronization is activated if syncDirection
is OC_SENDRECEIVE
(default). If syncDirection
is OC_SENDONLY
or OC_RECEIVEONLY
, then the developer must implement a custom transport. If the developer wishes to upload only changes, then set pushonly
=1. You cannot only download changes under the existing synchronization architecture.
This method returns when the synchronize completes. A return value of 0 indicates that the function has been executed successfully. If an error occurred, local errors are returned by ocDoSynchronize
, which are defined in ocerror.h
. For errors returned by the server, see the ol_sync.log
error log file, which is written into the working directory of the application. Each line in the error file has the following format:
<type>, <code>, <date>, <message>
Where:
<type>
: The type of the message, which can either be set to ERROR
or SUCCESS
.
<code>
: Error code of the last operation of the synchronization.
<date>
: Date and timestamp for when the synchronization completes. This is in the format of dd/mm/yyyy hh:mm:ss
.
<message>
: A readable message text.
If you create and set the progress callback function, then Oracle Database Lite invokes this callback function at different times while the ocDoSynchronize
method is executing. Create the callback function, as follows:
void myProgressProc ( void *env, int stage, int present);
When the ocDoSynchronize
invokes your myProgressProc
function, it provides the following information as input to your function:
env
—A pointer to the environment (ocEnv
structure) for the synchronization session. This provides the function to retrieve the userContext
pointer.
stage
—A number that denotes the stage in the synchronization process, which is one of the following values, where these values are defined in ocapi.h
:
Table 4-7 Description of the Stage Values
Stage Value | Description |
---|---|
|
Start of the prepare stage, which collects all internal data from the database and prepares to send the data to the server. |
|
Progress in the prepare stage. |
|
Prepare stage is completed. |
|
Starting to send the data to the server. |
|
Sending the data. |
|
Completed sending the data. |
|
Starting to receive data. |
|
Receiving data from the server. |
|
Completed receiving data from the server. |
|
Starting to process received data. |
|
Processing received data. |
|
Completed processing. Synchronization is finished. |
present
—The percentage completed in the particular stage that synchronization is in from 0 to 100.
If the function is a member of a class, then it must be defined as static.
After you create the callback function, set the function pointer in the ocEnv.fnProgress
(Table 4-2) to the address of your callback function. Save this with the ocSaveUserInfo
or ocSessionInit
methods.
Clears and performs a cleanup of the synchronization environment and buffers. This function must be invoked for every ocSessionInit
, even if the ocDoSynchronize
function is not performed.
int ocSessionTerm( ocEnv *env );
Table 4-8 lists the ocSessionTerm
parameter and its description.
Table 4-8 ocSessionTerm Parameters
Name | Description |
---|---|
|
Pointer to the environment structure returned by |
De-initializes all the structures and memory created by the ocSessionInit()
call. Users must ensure that they are always called in pairs.
Retrieves the synchronization error message and code. For a Symbian device, this function can also report if the synchronization is still in process.
int ocGetLastError( ocEnv *env, char *buf, int buf_size);
Table 4-9 lists the ocGetLastError
parameters.
The following sections describe how you can use Java on a WinCE device to build your own client synchronization initiation:
Using the Java interface for Mobile Sync client-side synchronization tasks, programs written in Java can use the functionality provided by the OCAPI library. The Java interface resides in the oracle.lite.msync
package.
The Java interface provides for the following functions:
Setting client side user profiles containing data such as user name, password, and server
Starting the synchronization process
Tracking the progress of the synchronization process
The Java interface consists of two files, olite40.jar
and msync_java.dll
. To use the Java interface, the olite40.jar
file must be included in the CLASSPATH
. The olite40.jar
file is located in the following directory.
<ORACLE_HOME
>\Mobile\classes
The msync_java.dll
file is located in the following directory.
<ORACLE_HOME
>\Mobile\bin
There are four parts to the Java interface. They are:
Sync
Class
SyncException
Class
SyncOption
Class
SyncProgressListener
Interface
The following sections describe the Java interface.
This class initiates synchronization by using the provided synchronization options. The parameters for the constructor are listed in Table 4-10.
Sync(SyncOption
option
)
Table 4-10 Sync Class Constructor
Parameter | Description |
---|---|
|
Instance of the |
To monitor the progress of the synchronization process, the public method SyncProgressListener
adds a progress listener to the object.
SyncProgressListener add(ProgressListener
listener
)
The parameters for the SyncProgressListener
method are described in Table 4-11.
Table 4-11 Sync Class Public Method
Parameter | Description |
---|---|
|
An object that implements the |
|
Starts a synchronization session and blocks that thread until synchronization is complete. |
|
Aborts the synchronization session. |
The following code demonstrates how to start a session using the default settings.
try { Sync mySync = new Sync( new SyncOption()); mySync.doSync(); } catch ( SyncException e) { System.err.println( "Sync Error:"+e.getMessage()); }
This class signals a non-recoverable error during the synchronization process. The SyncException()
class constructs a clear
object. The parameters for the constructor are listed inTable 4-12:
SyncException()
SyncException(int errorCode, string errorMessage)
Table 4-12 syncException Constructor Parameter Description
Parameter | Description |
---|---|
|
The error. Refer the Oracle Database Lite Message Reference. |
|
A readable text message that provides extra information. |
The methods for the SyncException
are listed in Table 4-13.
The SyncOption
class is used to define the parameters for the synchronization process. It can either be constructed manually, or can save or load data from the user profile.
SyncOption() SyncOption ( String user, String password, String syncParam, String transportDriver, String transportParam)
The parameters for the SyncOption
constructor are listed in Table 4-14:
Table 4-14 SyncOption Constructors
Parameter | Description |
---|---|
|
A string containing the name used for authentication by the Mobile Server. |
|
A string containing the user password. |
|
A string which defines an optional list of parameters for the synchronization session. See Section 4.2.5, "Java Interface SyncParam Settings" for more information. |
|
A string containing the name of the transport driver. Currently, only "HTTP" is supported. |
|
A string containing all the parameters needed for the specified driver to operate. See Section 4.2.6, "Java Interface TransportParam Parameters" for more information. |
|
A boolean value which limits synchronization to server tables flagged as high priority, otherwise all tables are synchronized. |
|
A boolean value which makes synchronization push only. |
These methods load and save the user profile. The parameters of the public methods are listed in Table 4-15:
Table 4-15 Sync Option Public Method Parameters
Parameter | Description |
---|---|
|
This loads the profile for the specified user name. If the user name is left null, the profile is loaded for the last user to synchronize. |
|
This saves the settings to the profile for the active user. |
|
This is used to set and get the current user. |
|
|
|
This is used to set and get the password. |
|
This is used to set and get the synchronization parameters. |
|
This is used to set and get the driver name. Release 5.0.2 supports the "HTTP" driver. |
|
Set and get the transport parameters. |
The following code example demonstrates how to start a synchronization session using the default settings:
SyncOption opt = new SyncOption ("sam","lion","pushonly","HTTP","server=server1;proxy=www-proxy.us.oracle.com;proxyPort=80"); opt.save();
The following example is of a client that creates the SyncOption
class and then performs the synchronization with the doSync
method.
import oracle.lite.mSync.*; public class JavaSyncClient{ String user = "SALES1"; String password = "MANAGER"; //Set the Sync params //Set syncParam to fullrefresh String syncParam = "";//fullrefresh; // Set the Transport params String transportDriver = "HTTP"; String trasportParam = "server=localhost"; /** * Constructor */ public JavaSyncClient() throws Exception{ //Create the SyncOption class SyncOption syncOpt = new SyncOption(user, password, syncParam, transportDriver, trasportParam); syncOpt.setSyncFlag("MYORDERS", "", (short) 0); //Save the options before the sync syncOpt.save(); //Create the Sync class Sync mySync = new Sync(syncOpt); //Perform the synchronization mySync.doSync(); } /** * main */ public static void main(String[] args) throws Exception { JavaSyncClient JavaSyncClient = new JavaSyncClient(); } }
The syncParam
is a string that can be passed when creating the SyncOption
object. It allows support parameters to be specified to the synchronization session. The string is constructed of name-and-value pairs. For example:
"name=value;name2=value2;name3=value3, ...;"
The names are not case sensitive, but the values are. The field names which can be used are listed in Table 4-16.
Table 4-16 Java Interface SyncParamSettings
Name | Value/Options | Description |
---|---|---|
|
N/A |
Clear all entries in the environment before applying any remaining settings. |
|
|
Use the appropriate selection to choose either SSL or AES stream encryption. |
|
N/A |
Use this setting to upload changes from the client to the server only, do not download. This is useful when data transfer is one way, client to server. |
|
N/A |
Do not download any new or updated applications. This is useful when synchronizing over slow connection or on a slow network. |
|
|
"SendOnly" is the same as "pushonly". "ReceiveOnly" allows no changes to be posted to the server. |
" |
N/A |
This setting prevents any new publications created since the last synchronization from being sent, and only synchronizes data from the current publications. |
|
|
The "enable" setting allows [Publication.Item] to be synchronized, "disable" prevents synchronization. |
|
|
|
|
N/A |
Forces a complete refresh. |
|
|
If set to "EMBEDDED", access to the database is by conventional ODBC, if set to "CLIENT" access is by multi-client ODBC. |
The first example enables SSL security and disables application deployment for the current synchronization session:
"security=SSL; noapps;"
The second example resets all previous settings, activates upload for the "Dept" table only:
"reset;pushOnly;tableFlag[TestApp.Emp]=disable;tableFlag[TestApp.Dept]=enable;"
The format of the TransportParam
string is used to set specific parameters using a string of name-and-value pairs, for example:
"name=value;name2=value2;name3=value3, ...;"
The names are not case sensitive, but the values are. The field names which can be used are listed in Table 4-17.
Table 4-17 TransportParam Parameters
Name | Value | Description |
---|---|---|
|
N/A |
Clear all entries in the environment before applying the rest of the settings. |
|
server hostname |
The hostname or IP address of the Mobile Server. |
|
proxy server hostname |
The hostname or IP address of the proxy server. |
|
port number |
The port number of the proxy server. |
|
cookie string |
The cookie to be used for transport. |
The example directs the Mobile Sync engine to use the server at "test.oracle.com
" through the proxy "proxy.oracle.com
" at port 8080:
"server=test.oracle.com;proxy=proxy.oracle.com;proxyPort=8080;"
Update the table flags for selective sync. Call this for each table to specify whether it should be synchronized(1) or not (0) for the next session. Selective sync only works if you have first performed at least one synchronization for the client. Then, set the flag so that on the next synchronize—that is, before the next invocation of the doSynchronize
method—a selective sync occurs.
The default setting is TRUE (1) for all the tables; that is, all tables are flagged to be synchronized. If you want to selectively synchronize specific tables, you must first disable the default setting for all tables and then enable the synchronization for only the specific tables that you want to synchronize.
Note:
Automatic synchronization is based on a different model than manual synchronization. Automatic synchronization operates on a transactional basis. Thus, the selective sync option is not supported when you use automatic synchronization for a publication, since we are no longer concerned with synchronization of only a subset of data.public void setSyncFlag(java.lang.String publication_name, java.lang.String table_name, short sync_flag) throws SyncException
Table 4-5 lists the name and description of parameters for the setSyncFlag
function.
Table 4-18 setSyncFlag Parameters
Name | Description |
---|---|
|
The name of the publication which is being synchronized. If the value for the |
|
This is the name of the snapshot. It is the same as the name of the |
|
If the |
This function allows client applications to select the way specific tables are synchronized.
Set sync_flag
for each table or each publication. If sync_flag
= 0, the table is not synchronized. To synchronize specific tables only, you must perform the following steps:
Disable the default setting, which is set to 1 (TRUE) for all the tables.
Example:
setSyncFlag(<publication_name>,null,0)
Where <publication_name>
must be replaced by the actual name of your publication, and where the value null
is specified to mean all the tables for that publication without exception.
Enable the selective sync for specific tables.
Example:
setSyncFlag(<publication_name>,<table_name>,1)
Alternatively, see the following code snippet on how to enable the selective sync flag for EVERY table EXCEPT the OrdersODB.TEST
table.
SyncOption op = new SyncOption(user, passwd, "noNewPubs","HTTP",server.toString()); op.setSyncFlag("","",(short)1); //turn on sync flag for all the tables op.setSyncFlag("","OrdersODB.TEST",(short)0); //turn off sync flag for OrdersODB.TEST
The SyncProgressListener is an interface that allows progress updates to be trapped during synchronization.
This class initiates synchronization by using the provided synchronization options. The parameters for the method are listed in Table 4-19:
void progress (int progressType, int completed);
Table 4-19 SyncProgressListener Abstract Method
Parameter | Description |
---|---|
|
This is set to one of the constants listed in Table 4-20. |
|
This is the percentage of completion for specific |
The names of the constants which report the synchronization progress are listed in Table 4-20.
Table 4-20 SyncProgressListener Interface Constants
Constant Name | Progress Type |
---|---|
|
States that the synchronization engine is in the initializing stage. The current and total counts are set to 0. |
|
States that the synchronization engine is preparing local data to be sent to the server. This includes getting locally modified data. For streaming implementations this takes a shorter amount of time. |
|
States that the synchronization engine is sending data to the network. The total count equals the number of bytes to be sent, and the current count equals the byte count being sent currently. |
|
States that the synchronization engine is receiving data from the server. The total count equals the number of bytes to be received, and the current count equals the byte count being received currently. |
|
States that the synchronization engine is applying the newly received data from the server to the local data stores. |
|
States that the synchronization engine has completed the synchronization process. |
This simple class implements the SyncProgressListener
.
class myProgressTracker implements SyncProgress Listener; { public void progress (int progressType, int completed) { System.out.println( "Status: "+progressType+"="+ completed+"%" ); } //progress }