MobiLink Synchronization User's Guide
Tutorial: Synchronizing Adaptive Server Anywhere Databases
MobiLink synchronization requires that you have data in a relational database, an ODBC data source for each database, and two compatible databases.
The first step is to create each of the databases. In this procedure, you build a consolidated database and a remote database using the dbinit utility from a command line.
The dbinit utility creates a database file with no user tables or procedures. You create your database schema when you define, within the newly-initialized file, user-defined tables and procedures.
To create your database files
Open a command prompt and navigate to the Samples\MobiLink\AutoScripting subdirectory of your SQL Anywhere 9 installation.
Create a consolidated database for this tutorial. Run the following command line:
dbinit consol.db
If this tutorial has been previously run on your computer, consol.db and consol.log may already exist. This will cause dbinit to fail. Delete these files before running dbinit.
Create the remote database for this tutorial. Run the following command line:
dbinit remote.db
If this tutorial has been previously run on your computer, remote.db and remote.log may already exist. This will cause dbinit to fail. Delete these files before running dbinit.
Verify the successful creation of these database files by listing the contents of the directory. You should see consol.db and remote.db in the listing.
You are now ready to build ODBC data sources through which you can connect to your Adaptive Server Anywhere databases.
For more information about creating ODBC data sources, see The Data Source utility.
To create ODBC data sources
Open a command prompt and navigate to the Samples\MobiLink\AutoScripting subdirectory of your SQL Anywhere 9 installation.
Create your ODBC data source for a consolidated database by running the following command line:
dbdsn -w test_consol -y -c "uid=DBA;pwd=SQL;dbf=consol.db;eng=Consol"
This command line specifies the following options:
-w Creates a data source definition.
-y Delete or overwrite data source without confirmation.
-c Specifies the connection parameters as a connection string.
For more information, see Data Source utility options.
Create an ODBC data source for a remote database by running the following command line:
dbdsn -w test_remote -y -c "uid=DBA;pwd=SQL;dbf=remote.db;eng=Remote"
Verify the successful creation of your data sources as follows.
To verify your new data sources
Choose Start
The ODBC Data Source Administrator appears.
Click the User DSN tab.
Scroll through the list to find the test_remote and test_consol data sources.
Select each data source and click Configure.
Test your data source by clicking the Test Connection button.
Click OK to close the ODBC Data Source Administrator.
The following procedure executes SQL statements using the Interactive SQL utility to create and populate tables in the consolidated database. It also creates tables and inserts synchronization subscriptions and publications into the remote database.
The SQL files, build_consol.sql and build_remote.sql, are created specifically for this tutorial.
To call and run your scripts using Interactive SQL
Open a command prompt and navigate to the Samples\MobiLink\AutoScripting subdirectory of your SQL Anywhere 9 installation.
Run the following command line:
dbisql -c "dsn=test_consol;astop=no" build_consol.sql
The SQL statements in build_consol.sql create and populate the emp and cust tables in the consolidated database.
This step includes astop=no
to instruct the server not to shut down when the dbisql utility shuts down.
Run the following command line:
dbisql -c "dsn=test_remote;astop=no" build_remote.sql
The SQL statements in build_remote.sql create the remote tables emp and cust, and insert synchronization subscriptions and publications.
Verify the creation of the emp and cust tables in the remote and consolidated databases using Interactive SQL.
Open Interactive SQL by typing dbisql at a command prompt. Connect using the test_consol DSN as DBA, using SQL as the password.
Execute the following SQL statement by typing it into the SQL Statements pane and pressing F9.
SELECT * FROM emp, cust
The tables in the consolidated database are populated with data.
Connect using the test_remote DSN and execute the following SQL statement:
SELECT * FROM emp, cust
The tables in the remote database are empty.
Leave the consolidated and remote databases running for the next lesson.
For more information about creating remote databases, see Creating a remote database.
For more information about creating subscriptions and publications, see Publishing data.
For more information about creating databases, see The Initialization utility and Creating a database using the dbinit command-line utility.
For more information about running Interactive SQL, see The Interactive SQL utility and Using Interactive SQL.
For more information about SELECT statements, see SELECT statement.