Sybase Business Intelligence Solutions - Database Management, Data Warehousing Software, Mobile Enterprise Applications and Messaging
Sybase Brand Color Bar
delete

Search for    in all of Sybase.com
view all search results right arrow
  blank
 
 
 
 
 
 
 
 
 
 

 
 
CLICK TO EXPAND NAVIGATION
CLICK TO EXPAND NAVIGATION
 
 
 
 
Support > Technical Documents > Document Types > Technote > SQL Anywhere Spatial Data Synchronization Sample

SQL Anywhere Spatial Data Synchronization Sample
 
RSS Feed
 
 
 

This demonstration synchronizes spatial data stored inside a consolidated database to a SQL Anywhere remote database.

Setup

If you install different versions of SQL Anywhere, please ensure that your Windows PATH environment variable includes the SQL Anywhere 12 directory before any other SQL Anywhere directories. The default directories are: C:\Program Files\SQL Anywhere 12\bin32 for Windows x86 and C:\Program Files\SQL Anywhere 12\bin64 for Windows x64.

  1. Open a Command Prompt and create a directory "SpatialSync" to store the sample's files.
  2. Extract the compressed archive SpatialSyncModel.zip into that directory. It contains the file "SpatialSyncModel.mlsm" that defines the synchronization model.
  3. Navigate to that directory and run the following commands to create the sample consolidated database:

copy "%SQLANY12%\scripts\mkdemo.sql" .

xcopy "%SQLANY12%\scripts\adata" .\adata\*.*

dbinit spatialsync.db

dbsrv12 spatialsync.db -x tcpip

dbisql -c "eng=spatialsync;uid=dba;pwd=sql" READ mkdemo.sql

dbdsn -c "uid=dba;pwd=sql;eng=spatialsync" -ws SpatialSyncDemo_ConsDB

Creating the Synchronization Project and Configuring the Consolidated Database

Using the Create Project wizard, you can define a new MobiLink project that contains all information regarding the MobiLink sychronization environment.

  1. Open Sybase Central and select Create a project from the MobiLink tasks.

MLProjectTask.JPG

  1. Name the project "Spatial Sync" and enter the location "C:\SpatialSync". Click Next.

MLProject01.JPG

  1. Check Add a consolidated database to the project and enter the following information:

Database display name: Central Database - Spatial Sync
Connection string: dsn=SpatialSyncDemo_ConsDB;uid=dba;pwd=sql

MLProject02.JPG

Click Next.

  1. Select Import an existing model and browse to the file "SpatialSyncModel.mlsm". Click Next.

MLProject03.JPG

  1. Check Add a Remote Schema Name to the project and enter the name "SpatialSyncSchema". Select SQL Anywhere as the database type.

MLProject04.JPG

Click Finish.

  1. Back at the main Sybase Central screen, click Add a consolidated database from the project setup tasks.

AddConsDBTask.JPG

  1. Enter the following information in the Add Consolidated Database wizard:

Database type: SQL Anywhere
Authentication: Database
User ID: dba
Password: sql
Action: Connect with an ODBC data source
ODBC Data Source Name : SpatialSyncDemo_ConsDB

AddConsDB01.JPG

Click Next and then Finish.

You will be asked to install the MobiLink system setup tables in the consolidated database. Click Yes to continue and then OK when the task completes.

Note: Sybase Central may issue an error at this point. If so, you may choose to send us the error report by clicking "Send Error Report". You may also decline to do so by clicking "Don't Send".

Click on "Resume" and then "OK" to continue working in Sybase Central. Click on "Cancel" to terminate the wizard. Please follow these additional steps:

  1. Switch to the folders view (use the toolbar) and expand MobiLink 12, Spatial Sync, and Consolidated Databases.
  2. Right-click on SpatialSyncDemo_ConsDB - DBA and select Check MobiLink System Setup from the popup menu.
  3. You will be asked to install the MobiLink system setup under the owner DBA, click Yes.
  4. Click OK after the operation completes.

Viewing the Synchronization Model

Switch to the folders view in Sybase Central (use the toolbar), expand "Sync Models" in the left panel and click on "SpatialSyncModel". The table mappings for this model appear on the right panel.

TableMappings.JPG

Notice that in this model, we are synchronizing two tables and one of them contains spatial data (SpatialShapes). For more information about synchronization models, please refer to the online documentation.

Deploying the Synchronization Model

  1. In the left panel, right-click on "SpatialSyncModel" and select Deploy. The Deploy Sychronization Model wizard appears.
  2. Specify to deploy all three components and click Next.
  3. Make sure to select "SpatialSyncDemo_ConsDB" as the consolidated database. Click Next.
  4. Click Yes to create the necessary directory structure.
  5. Select to create a new SQL Anywhere remote database. Click Next.
  6. Keep the default settings in the New SQL Anywhere Remtoe Database page. Click Next, then Yes to create the necessary directory structure.
  7. Set the user name to "ml_user" and password to "sql". Ensure to check the option to register this user in the consolidated database. Set the subscription to "SpatialSync_pub".

DeploySyncModel01.JPG

Click Next.

  1. Keep the TCP/IP setting for the stream parameter and change the port number if required. Click Next.
  2. Set the host name to your machine name. Use default settings for the remainder options, so click Finish. Click Yes on any dialogs that ask you to create the necessary directory structure.
  3. Click Close after the model successfully deploys.

Starting the MobiLink Server

The Deploy Synchronization Model wizard generated a batch file that you can use to start the MobiLink server inside the folder "mlsrv ". Using the Command Prompt, change to that directory and run the file as follows:

SpatialSyncModel_mlsrv "dsn=SpatialSyncDemo_ConsDB;UID=dba;PWD=sql"

The MobiLink server dialog appears and is ready to accept incoming synchornization requests.

MLServer.JPG

Synchronizing the Remote Database

The Deploy Synchronization Wizard also generated an empty SQL Anywhere remote database and a batch file to initiate data synchronization inside the folder "remote". Using the Command Prompt, change to that directory and the following commands:

  1. Start the remote database

    dbeng12 SpatialSyncModel_remote.db

  2. Synchronize the database

    SpatialSyncModel_dbmlsync "eng=SpatialSyncModel_remote;uid=dba;pwd=sql"

The MobiLink Synchronization Client window appears showing the progress. Click Shut down when the synchronization succeeds.

Viewing the Spatial Data in the Remote Database

  1. Using the Command Prompt, launch Interactive SQL and connect to the remote database by running the following command:

    dbisql -c "eng=SpatialSyncModel_remote;uid=dba;pwd=sql"

  2. In Interactive SQL, execute the following statement:

    SELECT * FROM GROUPO.SpatialShapes;

  3. In the Results panel, select the second row and click on the Shape column. A menu box appears at the end of the row. Click on this menu box.

dbisql.JPG

  1. Select View in Window to view the value of the column "Shape". Click the tab Spatial Preview to show the object.

    SquareObject.JPG

  2. Click OK to close the dialog.
  3. From the Tools menu, select Spatial Viewer and execute the statement SELECT * FROM GROUPO.SpatialShapes;
  4. All the spatial data is plotted in the viewer.

SpatialViewer.JPG

This concludes the demonstration. Close Interactive SQL.

Clean Up

In Sybase Central, click on "MobiLink 12" in the left panel. If you are asked to save changes, click No. The project "Spatial Sync" appears in the right panel. You may delete this project. Close Sybase Central.

Shut down the databases and the MobiLink synchronization server by running these commands:

dbstop -c "eng=SpatialSyncModel_remote;uid=dba;pwd=sql"

mlstop

dbstop -y -c "eng=spatialsync;uid=dba;pwd=sql"

Remove the sample's ODBC DSN by running this command:

dbdsn -y -ds SpatialSyncDemo_ConsDB

You may now delete the contents of the folder "SpatialSync" and remove that directory.


 

DOCUMENT ATTRIBUTES
Last Revised: May 16, 2012
Product: SQL Anywhere
Technical Topics: SQL Anywhere
  
Business or Technical: Technical
Content Id: 1067224
Infotype: Technote
 
 
 

 
© Copyright 2014, Sybase Inc. - v 7.6 Home / Contact Us / Help / Jobs / Legal / Privacy / Code of Ethics