• No results found

MobiLink Synchronization with Microsoft SQL Server and Adaptive Server Anywhere in 30 Minutes

N/A
N/A
Protected

Academic year: 2021

Share "MobiLink Synchronization with Microsoft SQL Server and Adaptive Server Anywhere in 30 Minutes"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

with Microsoft SQL Server

and Adaptive Server

Anywhere in 30 Minutes

(2)

Synchronizing Microsoft SQL Server with MobiLink 2

Introduction 2

Required Software 3

MobiLink Quick Start 3

Set up the Microsoft SQL Server consolidated database . . . 3

Set up the remote Adaptive Server Anywhere database . . . 3

Create scripts to upload and download data . . . 3

Run MobiLink synchronization . . . 4

MobiLink Synchronization to a Microsoft SQL Server Database in 30 Min-utes 4 Set up the Microsoft SQL Server consolidated database . . . 4

Set up the remote Adaptive Server Anywhere database . . . 6

Starting the MobiLink synchronization server . . . 9

Running the MobiLink synchronization client utility . . . 9

(3)

Synchronizing Microsoft SQL Server with

MobiLink

This paper demonstrates how to synchronize data between a Microsoft SQL Server consolidated database and Adaptive Server Anywhere remote databases. It shows how to set up a simple synchronization from scratch using an SQL Server sample database. A single remote database is set up in this paper.

Introduction

MobiLink enables synchronization between a central ODBC-compliant

consolidated database and many Adaptive Server Anywhere or UltraLite remote databases. MobiLink synchronization is a component of SQL Anywhere Studio, iAnywhere Solutions’ comprehensive package for mobile data management. The following diagram shows the major parts of the synchronization system.

MobiLink synchronization server network ASA Adaptive Server Anywhere or UltraLite MobiLink clients Consolidated database server Remote database server Remote database

consolidated database This database contains the central copy of all information in the synchronization system.

consolidated database server The server, or DBMS, that manages the consolidated database. This server can be one of the following

ODBC-compliant databases: Adaptive Server Anywhere, Adaptive Server Enterprise, Oracle, IBM DB2, or Microsoft SQL Server. In this tutorial the consolidated database server is SQL Server.

ODBC connection All communication between the MobiLink synchronization server and the consolidated database occurs through an ODBC connection. ODBC allows the synchronization server to utilize a variety of consolidated database systems. In this tutorial, the ODBC connection is made with the SQL Server ODBC driver.

(4)

synchronization process and provides the interface between all MobiLink clients and the consolidated database server.

network The connection between the MobiLink synchronization server and the MobiLink client (dbmlsync or UltraLite) can use a number of network protocols. This tutorial uses the TCP/IP protocol.

MobiLink client The client can be installed on a handheld device such as a Palm Pilot or Pocket PC, a server or desktop computer, or an embedded device such as a cell phone or vending machine. Two types of clients are supported: Adaptive Server Anywhere (used in this tutorial) and UltraLite. Either or both may be used in a single MobiLink installation.

Required Software

♦ A full SQL Anywhere Studio 9.0.1 installation.

♦ A full installation of SQL Server 2000 including the Northwind sample database.

MobiLink Quick Start

Following is an overview of the steps required to set up a Microsoft SQL Server database for MobiLink synchronization. Each step is illustrated in detail later in this paper.

Set up the Microsoft SQL Server consolidated database

1. Run a pre-defined SQL script (syncmss.sql) to prepare your Microsoft SQL Server database to be a MobiLink consolidated database. This adds MobiLink tables and stored procedures.

2. Define an ODBC data source for the Microsoft SQL Server database using the SQL Server ODBC driver.

Set up the remote Adaptive Server Anywhere database

1. Create an Adaptive Server Anywhere database.

2. Migrate a subset of your Microsoft SQL Server schema to the Adaptive Server Anywhere database, including any synchronized tables.

3. Create a remote synchronization publication, synchronization user, and synchronization subscription.

Create scripts to upload and download data

(5)

♦ How data uploaded from the remote database is to be applied to the consolidated database.

♦ What data should be downloaded from the consolidated database.

These scripts may be individual statements or stored procedure calls stored in your consolidated database. For simple cases you can instruct the MobiLink synchronization server to generate scripts automatically at runtime using a command-line option.

Run MobiLink synchronization

♦ Start the MobiLink synchronization server (dbmlsrv9).

This enables the MobiLink server to listen for client synchronization requests.

♦ Run the MobiLink synchronization client utility (dbmlsync) to initiate a synchronization session.

MobiLink Synchronization to a Microsoft

SQL Server Database in 30 Minutes

The previous section sketched the steps necessary to set up synchronization. This section walks through all these steps in detail.

Note:

Some examples in this tutorial are presented with Sybase Central. Sybase Central is a database management tool that provides Adaptive Server Anywhere database settings, properties, and utilities in a graphical user interface. It relies heavily on the use of wizards. However, Sybase Central, Interactive SQL, and the command line may be used interchangeably.

Set up the Microsoft SQL Server consolidated database

This tutorial uses Northwind, a sample database commonly used for Microsoft SQL Server demonstrations and training.

Installing MobiLink system tables in the Microsoft SQL Server database MobiLink comes with a script called syncmss.sql located in the MobiLink\setup subdirectory of your SQL Anywhere installation. syncmss.sql is a file containing SQL statements to prepare Microsoft SQL Server databases for use as MobiLink consolidated databases. It creates a series of system tables and procedures prefaced with ML_. MobiLink works with these tables and stored procedures during the synchronization process.

To install MobiLink system tables

(6)

Choose Start➤Programs➤Microsoft SQL Server➤Query Analyser. 2. Select the Northwind sample database.

From the DB dropdown menu in the toolbar, choose Northwind. 3. Execute the SQL script.

Open syncmss.sql:

From the File menu, choose Open. Now select syncmss.sql, located in the

MobiLink\setup subdirectory of your SQL Anywhere installation.

♦ Press F5 to execute the Query.

Define an ODBC data source for the consolidated database

Use the Microsoft SQL Server ODBC driver to define an ODBC data source for the Northwind sample database.

To define an ODBC data source for the consolidated database

1. Start the ODBC Administrator:

Fromt the Start menu, choose Programs➤SQL Anywhere 9➤Adaptive Server Anywhere➤ODBC Administrator.

The ODBC Data Source Administrator appears. 2. On the User DSN tab, click Add.

The Create New Data Source dialog appears. 3. Select SQL Server and click Finish.

The Microsoft SQL Server DSN Configuration wizard appears.

4. Enter sqlserver_consolidated as the Name of the data source. Click Next to continue.

5. On the next page, select the appropriate authentication mode for your SQL connection. Click Next to continue.

6. Select Northwind as the default database. Remove check marks from the following:

♦ Use ANSI quoted identifiers.

♦ Use ANSI nulls, paddings and warnings.

7. Accept the remaining default settings and click Finish. Synchronization scripts

In this tutorial, you do not manually add synchronization scripts. When you start the MobiLink synchronization server with special command-line options, default scripts are automatically generated. You can use these scripts as a starting point for generating your own scripts.

(7)

Set up the remote Adaptive Server Anywhere database

MobiLink is designed for synchronization involving a consolidated database server and a large number of mobile databases. In this section, you create a single remote database, migrate a selected portion of the consolidated schema, and create a synchronization publication, user, and subscription.

One way to create an Adaptive Server Anywhere database is to use the dbinit command-line utility. For this tutorial, we will call the remote database remote1. ❖ To create and start a new Adaptive Server Anywhere remote database

1. At a command prompt, navigate to the directory where you would like to create the database.

2. Type the following command to create the database:

dbinit remote1.db

3. Now, to start the database, type:

dbeng9 remote1.db

Migrating a subset of the Northwind database Microsoft SQL Server schema Migrating a subset of the Northwind schema involves:

♦ Connecting to the remote database.

♦ Creating a remote server and external login.

♦ Using the Sybase Central Data Migration wizard.

To migrate a subset of your Microsoft SQL Server schema to the Adaptive Server Anywhere database

1. Start Sybase Central.

From the Start menu, choose Programs➤SQL Anywhere 9➤Sybase Central. 2. Connect to the remote database:

♦ Select Adaptive Server Anywhere 9 in the left pane of Sybase Central.

♦ From the File menu choose Connect. The Connect dialog appears.

On the Identification tab, enter DBA as the User ID and SQL as the password. On the Database tab, enter remote1 as the server name.

♦ Click OK to connect.

3. Create a remote server and external login:

♦ Start the Remote Server Creation wizard.

In the left pane, select the Remote Servers folder. From the File menu choose New➤Remote Server.

(8)

Name the remote server my_sqlserver. Click Next to continue.

♦ Choose Microsoft SQL Server as the type of server.

On the next page of the wizard, enter sqlserver_consolidated in the connection information section.

♦ On the final page of the wizard, choose Create an External Login. Enter the Login name and Password to connect to your Microsoft SQL Server instance.

♦ Click Finish to exit the Remote Server Creation wizard. 4. Migrate the Microsoft SQL Server schema:

♦ In the left pane, select the Adaptive Server Anywhere 9 plug-in. In the right pane, select the Utilities tab and double-click Migrate Database:

The Data Migration wizard starts.

Select remote1 as the destination database.

On the next page, select my_sqlserver as the remote server. Click Next to continue.

(9)

♦ On the final page of the wizard, clear the Migrate the data option:

♦ Click Finish.

The migration of the Microsoft SQL Server schema is now complete.

To create a remote synchronization publication, synchronization user, and synchronization subscription

1. Start Interactive SQL:

♦ In the left pane of Sybase Central, select the remote1 database. From the File menu choose Open Interactive SQL.

The Connect dialog appears. 2. Enter synchronization information:

(10)

CREATE PUBLICATION sample_pub (TABLE Customers, TABLE Employees); CREATE SYNCHRONIZATION USER ml_user1;

CREATE SYNCHRONIZATION SUBSCRIPTION TO sample_pub FOR ml_user1 TYPE TCPIP ADDRESS ’host=localhost’ OPTION scriptversion=’ver1’;

Now you have prepared the remote and consolidated databases and can begin with the synchronization process.

Starting the MobiLink synchronization server

To run the MobiLink synchronization server (dbmlsrv9)

1. At a command prompt, type the following on a single line:

dbmlsrv9 -c "dsn=sqlserver_consolidated" -o serverOut.txt -v+ -dl -za -zu+ -x tcpip

Note: MobiLink technology also allows you to obfuscate command-line options

in a command file. Consult MobiLink documentation about the dbfhide utility for more information.

The following table describes each option used with the dbmlsrv9 utility. The options -o, -v, and -dl provide debugging and troubleshooting information. Using these logging options is appropriate in a development environment. For performance reasons, -v and -dl are typically not used in production.

Option Description

-c Precedes the connection string.

-o Specifies the message log file serverOut.txt.

-v+ The -v option specifies what information is logged. Using -v+ sets maximum verbose logging.

-dl Displays all log messages on screen.

-za Turns automated scripting ON. The -za option is typically used to generate scripts as a starting point for writing your own scripts. Scripts are generated the first time that a remote synchronizes. If the given script version already exists, -za has no effect.

-zu+ Adds new users automatically.

-x Sets the communications protocol and parameters for MobiLink clients.

A dialog appears to indicate the MobiLink synchronization server is ready to handle requests:

Running the MobiLink synchronization client utility

(11)

To start the synchronization client

1. At a command prompt, type the following on a single line:

dbmlsync -c "eng=remote1;uid=dba;pwd=sql" -o rem1.txt -v+ -e "SendColumnNames=on"

Below is a description of each option: Option Description

-c Precedes the connection string. -o Specifies the message log file rem1.txt.

-v The -v option specifies what information is logged. Using -v+ sets maximum verbose logging.

-e The -e option specifies extended options. In this case it is used to send column names to the MobiLink synchronization server (re-quired for automatic scripting). The SendColumnNames parameter is typically used together with the -za or -ze option on the MobiLink synchronization server for automatically generating synchronization scripts.

Once you have started the MobiLink synchronization client, an output screen appears indicating that the MobiLink synchronization succeeded. The data in the Microsoft SQL Server tables now appears in your Adaptive Server Anywhere database.

You can check that synchronization has succeeded by checking row values in the remote database.

To check row values on the remote database

1. Open Sybase Central and connect to the remote1 database using the Adaptive Server Anywhere 9 plug-in (if not already connected).

2. Open the Tables folder and choose the Employees Table. On the right pane, select the Data tab.

(12)

Legal Notice

Copyright © 2004 iAnywhere Solutions, Inc. All rights reserved. Sybase, the Sybase logo, iAnywhere Solutions, the iAnywhere Solutions logo, Adaptive Server, MobiLink, and SQL Anywhere are trademarks of Sybase, Inc. or its subsidiaries. All other trademarks are property of their respective owners. The information, advice, recommendations, software, documentation, data, services, logos, trademarks, artwork, text, pictures, and other materials

(collectively, “Materials”) contained in this document are owned by Sybase, Inc. and/or its suppliers and are protected by copyright and trademark laws and international treaties. Any such Materials may also be the subject of other intellectual property rights of Sybase and/or its suppliers all of which rights are reserved by Sybase and its suppliers.

Nothing in the Materials shall be construed as conferring any license in any Sybase intellectual property or modifying any existing license agreement. The Materials are provided “AS IS”, without warranties of any kind. SYBASE EXPRESSLY DISCLAIMS ALL REPRESENTATIONS AND WARRANTIES RELATING TO THE MATERIALS, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. Sybase makes no warranty,

representation, or guaranty as to the content, sequence, accuracy, timeliness, or completeness of the Materials or that the Materials may be relied upon for any reason.

Sybase makes no warranty, representation or guaranty that the Materials will be uninterrupted or error free or that any defects can be corrected. For purposes of this section, ‘Sybase’ shall include Sybase, Inc., and its divisions, subsidiaries, successors, parent companies, and their employees, partners, principals, agents and representatives, and any third-party providers or sources of Materials.

Contact Us

iAnywhere Solutions Worldwide Headquarters One Sybase Drive, Dublin, CA, 94568 USA

Phone 1-800-801-2069 (in US and Canada)

Fax 1-519-747-4971

References

Related documents

TekSIP Route Server uses built-in Microsoft Access database by default.. If you plan to use a Microsoft SQL Server database, create database and “Routes” table

Stored procedures The Database Connector for Microsoft SQL Server allows you to create a set of Micro Focus stored procedures for accessing database tables. You can create

Started at Volvo Financial Services (VFS) as a Microsoft BI consultant to create several SSRS 2008 reports, migrate a Reporting Server (SSRS, SSIS and SQL Server) to SQL Server 2008

If you choose the option ‘Create a new database on a different SQL Server’, you will need to provide information on the SQL Server instance you wish to create the database on..

Lesson: Using Data Collector Introducing Data Collector Data Collector Concepts Configuring Data Collector Demo - Configuring Data Collector Lab Demonstration: Exercise 1

• Exercise 3: (Level 300) Implementing SQL Server Clustering After completing this module, students will be able to:. • Describe the factors affecting

This three-day instructor-led course provides students with product knowledge and skills needed to implement a Microsoft SQL Server 2005 database.. The course focuses on

Click next at least one specified schema is sql server db designer is an existing databases you can create db schema sql server resource and extensive planning for.. All products