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

SAP Sybase SQL Anywhere 16.0 » UltraLite - Java Programming » Tutorial: Building a BlackBerry application » Part 2: Using MobiLink to synchronize the BlackBerry application

 

Lesson 4: Starting the MobiLink server and synchronizing the application

In this lesson, you start the MobiLink server and synchronize the UltraLite Java edition database with the SQL Anywhere consolidated database.

Prérequis

This lesson assumes you have completed all preceding lessons. See Lesson 1: Setting up your MobiLink consolidated database.

Contexte et remarques

Before you can run the BlackBerry application and synchronize, the MobiLink server must be running. The MDS Simulator must also be running to provide a communication channel between the device simulator and MobiLink.

 Task
  1. Start MobiLink by running the following command from c:\HelloBlackBerry\database\:

    mlsrv16 -c "DSN=HelloBlackBerry" -v+ -x http(port=8081) -ot ml.mls

    The -c option connects MobiLink to the SQL Anywhere database. The -v+ option sets a high level of verbosity so that you can follow what is happening in the MobiLink server messages window. The -x option indicates the port number being used for the communications. The -ot option specifies that a log file (ml.mls) is to be created in the directory where you started the MobiLink server.

  2. Run the MDS simulator so that the BlackBerry simulator can communicate over a network.

    Click Start » Programs » Research In Motion » BlackBerry Email And MDS Services Simulator 4.1.4 » MDS.

  3. Add names to the MobiLink consolidated database so that your application updates the UltraLite Java edition database when synchronizing.

    1. Run the following command to start Interactive SQL and connect to the SQL Anywhere database:

      dbisql -c dsn=HelloBlackBerry
    2. Execute the following SQL statement in Interactive SQL to add names to the Names table:

      INSERT Names (Name) VALUES ('Jane Smith');
      INSERT Names (Name) VALUES ('David Smith');
      COMMIT;
    3. Close Interactive SQL.

      Click File » Exit.

  4. Run the simulator from Eclipse.

    In the Package Explorer window, click Application.java, and then click Run » Run As » BlackBerry Simulator.

    Note

    If multiple projects are open in your workspace, click Run » Run Configurations, select HelloBlackBerry, and then click Run.

    The HelloBlackBerry project compiles and then the simulator window appears.

    Ensure that the project compiles without errors by selecting the Problems tab in Eclipse.

  5. From the simulator menu, click File » Load Java Program.

  6. Browse to the \UltraLite\UltraLiteJ\BlackBerry4.2\ directory of your SQL Anywhere installation and open the UltraLiteJ16.cod file.

    Note

    You may need to copy UltraLiteJ16.cod and the DBG files to the working simulator directory (for example, C:\Eclipse\plugins\net.rim.ejde.componentpack6.0.0_6.0.0.0.26\components\simulator\) to run the application. When copied, you do not need to load the Java program from the simulator menu.

  7. From the simulator menu, click Simulate » Set IT Policy.

    The Set IT Policy window appears.

  8. In the Policy field, click Allow Third Party Apps To Use Persistent Store » >>.

  9. Click Set and then click Close.

  10. Launch your application.

    In the simulator window, navigate to Downloads and then run the HelloBlackBerry application.

    A screen appears that displays the Hello BlackBerry title bar, the Status: Connected text, and a Name field.

  11. Synchronize the application with the MobiLink server.

    Click *EMPTY* and then choose Sync.

    Jane Smith and David Smith appear in the list, which indicates that the application was able to synchronize with the MobiLink consolidated database. If you query the names in the Names table from Interactive SQL, you should see that any names you have entered in the simulator have reached the server.

  12. Stop the simulation.

    In the simulator window, click File » Exit.

Résultat

The UltraLite Java edition and SQL Anywhere consolidated databases are synchronized.

Suivant

Proceed to Cleaning up.