Skip Headers
Oracle® Database Lite Developer's Guide for Java
10g (10.0.0)
Part No. B13811-01
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

5 Java Support on Windows CE

This chapter describes Java support for Windows CE devices using the Java Interface. Topics include:

5.1 Overview

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:

The Java interface consists of two files, mSync.jar and msync_java.dll. To use the Java interface, the mSync.jar file must be included in the classpath. The mSync.jar file is located in the following directory.

&fmv127;\Mobile\classes

The msync_java.dll file is located in the following directory.

&fmv128;\Mobile\bin

There are four parts to the Java interface. They are:

The following sections describe the Java interface.

5.2 Sync Class

This class initiates synchronization by using the provided synchronization options. The parameters for the constructor are listed in Table 5-1.

Constructors

Sync(SyncOption option)

Table 5-1 Sync Class Constructor

Parameter Description
option Instance of the SyncOption Class. This contains all the parameters needed to perform synchronization.

Public Methods

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

Table 5-2 Sync Class Public Method

Parameter Description
listener An object that implements the ProgressListener interface. The synchronization object calls the progress() function of this object to notify it of the synchronization progress.
void doSync () Starts a synchronization session and blocks that thread until synchronization is complete.
void abort () 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());
}
 

5.3 SyncException Class

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 5-3:

Constructors

SyncException()

SyncException(int errorCode, string errorMessage)

Table 5-3 syncException Constructor Parameter Description

Parameter Description
errorCode The error. Refer the Oracle Database Lite Message Reference.
errorMessage A readable text message that provides extra information.

Public Methods

The methods for the SyncException are listed in Table 5-4.

Table 5-4 SyncExceptionClass Public Methods

Parameters Description
int getErrorCode() Gets the error code.
String getErrorMessage Gets the error message.

5.4 SyncOption Class

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.

Constructors

SyncOption()
 
SyncOption
 
   ( String user,
 
     String password,
 
     String syncParam,
 
     String transportDriver,
 
     String transportParam)

The parameters for the SyncOption constructor are listed in Table 5-5:

Table 5-5 SyncOption Constructors

Parameter Description
user A string containing the name used for authentication by the Mobile Server.
password A string containing the user's password.
syncParam A string which defines an optional list of parameters for the synchronization session. See Section 5.5, "Java Interface SyncParam Settings" for more information.
transportDriver A string containing the name of the transport driver. Currently, only "HTTP" is supported.
transportParam A string containing all the parameters needed for the specified driver to operate. See Section 5.6, "Java Interface TransportParam Parameters" for more information.
priority A boolean value which limits synchronization to server tables flagged as high priority, otherwise all tables are synchronized.
pushOnly A boolean value which makes synchronization push only.

Public Methods

These methods load and save the user profile. The parameters of the public methods are listed in Table 5-6:

Table 5-6 Sync Option Public Method Parameters

Parameter Description
void load(String username) 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.
void save() This saves the settings to the profile for the active user.
void setUser(String username) This is used to set and get the current user.
String getuser()
void setPassword(String password)String getPassword() This is used to set and get the password.
void setSyncParam(String syncParam) string getSyncParam() This is used to set and get the synchronization parameters.
void setTransportDriver(String driverName) String getTransportDriver() This is used to set and get the driver name. Release 5.0.2 supports the "HTTP" driver.
void setTransportParam(String transportParam) String getTransportParam() Set and get the transport parameters.

Example

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();

5.5 Java Interface SyncParam Settings

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

Table 5-7 Java Interface SyncParamSettings

Name Value/Options Description
"reset" N/A Clear all entries in the environment before applying any remaining settings.
"security" SSL or CAST5 Use the appropriate selection to choose either SSL or CAST5 stream encryption.
"push only" 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.
"noapps" N/A Do not download any new or updated applications. This is useful when synchronizing over slow connection or on a slow network.
"syncDirection" "sendonly" "receiveonly" "SendOnly" is the same as "pushonly".

"ReceiveOnly" allows no changes to be posted to the server.

"noNewPubs" N/A This setting prevents any new publications created since the last synchronization from being sent, and only synchronizes data from the current publications.
"tableFlag" "enable" The "enable" setting allows [Publication.Item] to be synchronized, "disable" prevents synchronization.
[Publication.Item] "disable"
"fullrefresh" N/A Forces a complete refresh.
"clientDBMode" "EMBEDDED" or "CLIENT" If set to "EMBEDDED", access to the database is by conventional ODBC, if set to "CLIENT" access is by multi-client ODBC.

Example 1

The first example enables SSL security and disables application deployment for the current synchronization session:

"security=SSL; noapps;"

Example 2

The second example resets all previous settings, activates upload for the "Dept" table only:

"reset;pushOnly;tableFlag[TestApp.Emp]=disable;tableFlag[TestApp.Dept]=enable;"

5.6 Java Interface TransportParam Parameters

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

Table 5-8 TransportParam Parameters

Name Value Description
"reset" N/A Clear all entries in the environment before applying the rest of the settings.
"server" server hostname The hostname or IP address of the Mobile Server.
"proxy" proxy server hostname The hostname or IP address of the proxy server.
"proxyPort" port number The port number of the proxy server.
"cookie" cookie string The cookie to be used for transport.

Example

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;"

5.7 SyncProgress Listener Service

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 5-9:

Method

void progress
 
   (int progressType,
 
    int completed);

Table 5-9 SyncProgressListener Abstract Method

Parameter Description
progressType This is set to one of the constants listed in Table 5-10.
completed This is the percentage of completion for specific progressType.

The names of the constants which report the synchronization progress are listed in Table 5-10.

Table 5-10 SyncProgressListener Interface Constants

Constant Name Progress Type
PT_INT States that the synchronization engine is in the initializing stage. The current and total counts are set to 0.
PT_PREPARE_SEND 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.
PT_SEND 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.

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

PT_PROCESS_RECV States that the synchronization engine is applying the newly received data from the server to the local data stores.
PT_COMPLETE States that the synchronization engine has completed the synchronization process.

Example

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
 }