MobiLink Synchronization User's Guide
Writing Synchronization Scripts in Java
Java synchronization example
This section describes a working example of Java synchronization logic. Before you try to use this class or write your own class, use the following checklist to ensure you have all the pieces in place before compiling the class.
Plan your desired functionality using, for example, pseudocode.
Create a map of database tables and columns.
Set up the consolidated database by ensuring you have specified in the MobiLink system tables the language type and location of the Java synchronization methods.
For more information see Setting up Java synchronization logic.
Create a list of associated Java classes that are called during the running of your Java class.
Have a location for your Java classes that is in the classpath for MobiLink synchronization server.
The Java synchronization logic for this example points to the associated Java files and classes that contain functionality needed for the example to work. It will show you how to create a class CustEmpScripts
. It shows you how to set up a synchronization context for the connection. Finally, the example provides Java methods to
Authenticate a MobiLink user
Perform download and upload operations using cursors for each database table.
The tables to be synchronized are emp and cust. The emp table has three columns called emp_id, emp_name and manager. The cust table has three columns called cust_id, cust_name and emp_id. All columns in each table are synchronized. The mapping from consolidated to remote database is such that the table names and column names are identical in both databases. One additional table, an audit table, is added to the consolidated database.
The files used in the example are included in the Samples\MobiLink\JavaAuthentication directory.