When you install SQL Anywhere, the installer automatically sets the location of the MobiLink server API for Java classes. When you start the MobiLink server, it automatically includes these classes in your classpath. The MobiLink server API for Java classes are installed to the java\mlscript.jar subdirectory of your SQL Anywhere installation.
To implement synchronization scripts in Java
Create your own class or classes. Write a method for each required synchronization script. These methods must be public. The class must be public in the package.
See Methods.
Each class with non-static methods should have a public constructor. The MobiLink server automatically instantiates each class the first time a method in that class is called.
See Constructors.
When compiling the class, you must include the JAR file java\mlscript.jar.
For example,
javac MyClass.java -classpath "c:\Program Files\SQL Anywhere 11\java\mlscript.jar" |
In the MobiLink system tables on your consolidated database, specify the name of the package, class, and method to call for each synchronization script. One class is permitted per script version.
For example, you can add this information to the MobiLink system tables using the ml_add_java_connection_script stored procedure or the ml_add_java_table_script stored procedure.
For example, the following SQL statement, when run in a SQL Anywhere database, specifies that for the script version ver1, myPackage.myClass.myMethod should be run whenever the authenticate_user connection-level event occurs. The method that is specified must be the fully qualified name of a public Java method, and the name is case sensitive.
call ml_add_java_connection_script( 'ver1', 'authenicate_user', 'myPackage.myClass.myMethod' ) |
For more information about adding scripts, see:
Instruct the MobiLink server to load classes. A vital part of setting up Java synchronization logic is to tell the virtual machine where to look for Java classes. There are two ways to do this:
mlsrv11 -c "dsn=consolidated1" -sl java (-cp %classpath%;c:\local\Java\myclasses.jar) |
The MobiLink server automatically appends the location of the MobiLink server API for Java classes (java\mlscript.jar) to the set of directories or jar files. The -sl java option also forces the Java VM to load on server startup.
For more information about the available Java options, see -sl java option.
SET classpath=%classpath%;c:\local\Java\myclasses.jar |
If your system classpath includes your Java synchronization logic classes, you do not need to make changes to your MobiLink server command line.
You can use the -sl java option to force the Java virtual machine to load at server startup. Otherwise, the Java virtual machine is started when the first Java method is executed.
For more information about the available Java options, see -sl java option.
On UNIX, if you want to load a specific JRE, you should set the LD_LIBRARY_PATH (LIBPATH on AIX, SHLIB_PATH on HP-UX) to include the directory containing the JRE. The directory must be listed before any of the SQL Anywhere installation directories.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |