Lesson 2: Register your Java or .NET scripts for the authenticate_user event

In this lesson, you register the MobiLinkAuth authenticateUser method for the authenticate_user synchronization event. You add this script to CustDB, the MobiLink sample database.

MobiLink database sample

SQL Anywhere ships with a SQL Anywhere sample database (CustDB) that is already set up for synchronization. The CustDB ULCustomer table, for example, is a synchronized table supporting a variety of table-level scripts.

CustDB is designed to be a consolidated database server for both UltraLite and SQL Anywhere clients. The CustDB database has a DSN called SQL Anywhere 11 CustDB.

To register the authenticateUser method for the authenticate_user event

  1. Connect to the sample database using Interactive SQL.

    Run the following command:

    dbisql -c "dsn=SQL Anywhere 11 CustDB"
  2. Use the ml_add_java_connection_script or ml_add_dnet_connection_script stored procedure to register the authenticateUser method for the authenticate_user event.

    For Java, execute the following command in Interactive SQL:

    call ml_add_java_connection_script(
    'custdb 11.0',
    'authenticate_user',
    'MobiLinkAuth.authenticateUser');
    commit;

    For .NET, execute the following command in Interactive SQL:

    call ml_add_dnet_connection_script(
    'custdb 11.0',
    'authenticate_user',
    'MobiLinkAuth.authenticateUser');
    commit;

In the next lesson, you start the MobiLink server and load your class file or assembly.

Further reading

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

For more information about the ml_add_java_connection_script, see ml_add_java_connection_script system procedure.

For more information about the ml_add_dnet_connection_script, see ml_add_dnet_connection_script system procedure.