Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » MobiLink - Getting Started » Tutorial: Using Java Synchronization Logic

Lesson 1: Compile the CustdbScripts Java class Next Page

Lesson 2: Specify class methods to handle events

CustdbScripts.class, created in the previous lesson, encapsulates the methods UploadInsert and DownloadCursor. These methods contain implementations for the ULCustomer upload_insert and download_cursor events, respectively.

In this section, you specify class methods for table-level events using two approaches:

To specify CustdbScripts.UploadInsert to handle the ULCustomer upload_insert event
  1. Connect to the sample database using the Sybase Central MobiLink Admin mode:

  2. Delete the existing upload_insert event for the ULCustomer table:

  3. Create a new upload_insert event for the ULCustomer table:

  4. Double-click the upload_insert script to open it. Replace the contents of the script with the fully qualified method name CustdbScripts.UploadInsert and save the script. From the file menu, choose Save.

  5. Exit Sybase Central.

This step used Sybase Central to specify a Java method as the script for the ULCustomer upload_insert event.

Alternatively, you can use the ml_add_java_connection_script and ml_add_java_table_script stored procedures. Using these stored procedures is more efficient, especially if you have a large number of Java methods to handle synchronization events.

See ml_add_java_connection_script and ml_add_java_table_script.

To specify CustdbScripts.DownloadCursor() to handle the ULCustomer download_cursor event
  1. Connect to the sample database with Interactive SQL.

  2. Execute the following command in Interactive SQL:

    CALL ml_add_java_table_script(
    'custdb 10.0',

    Following is a description of each parameter:

    custdb 10.0The script version.
    ULCustomerThe synchronized table.
    download_cursorThe event name.
    CustdbScripts.DownloadCursorThe fully qualified Java method.
  3. Exit Interactive SQL.

In this lesson, you specified your Java methods to handle ULCustomer table-level events. The next lesson ensures that the MobiLink server loads the appropriate class files and the MobiLink server API.

Further reading

For more information about adding scripts with stored procedures, see ml_add_java_connection_script and ml_add_java_table_script.

For general information about adding and deleting synchronization scripts, see Adding and deleting scripts.