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

SQL Anywhere 12.0.1 » MobiLink - Getting Started » MobiLink tutorials » Tutorial: Using Java synchronization logic


Lesson 3: Subscribing a script to the upload_insert event

This lesson assumes you have completed all preceding lessons. See Lesson 1: Compiling the CustdbScripts Java class with MobiLink references.

In this lesson, you use Sybase Central to specify a Java method as the script for the ULCustomer upload_insert event. You connect to the CustDB database using Sybase Central, replace the upload_insert SQL script with a Java script, and specify CustdbScripts.UploadInsert to handle the 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 methods to handle synchronization events. See ml_add_java_connection_script system procedure and ml_add_java_table_script system procedure.

 Subscribe CustdbScripts.UploadInsert to the upload_insert event for the ULCustomer table
  1. In Sybase Central, click View » Folders.

  2. In the left pane of Sybase Central under MobiLink 12, expand mljava_project, Consolidated Databases, mljava_db, Synchronized Tables, ULCustomer.

  3. In the right pane, select the custdb 12.0 upload_insert table script. Click Edit » Delete.

  4. Create a new upload_insert table script.

    1. Click File » New » Table Script.

    2. In the For Which Version Do You Want To Create The Table Script list, click custdb 12.0.

    3. In the Which Event Should Cause The Table Script To Be Executed list, click upload_insert, and click Next.

    4. Select Create A New Script Definition, and select Java.

    5. Click Finish.

  5. Enter the Java method name to load for the custdb 12.0 upload_insert table script.

    In the right pane of Sybase Central, use the following Java script for the upload_insert event:

  6. Click File » Save to save the script.

  7. Close Sybase Central.

  8. Proceed to Lesson 4: Specifying class methods to handle events.