MobiLink supports IBM DB2 UDB for Linux, Unix, and Windows. MobiLink does not support IBM DB2 for AS/400 or mainframe.
To set up DB2 to work as a MobiLink consolidated database, you must run a setup procedure that adds MobiLink system tables, stored procedures, triggers, and views that are required for MobiLink synchronization. There are multiple ways you can do this:
Run the syncdb2long.sql setup script, located in the MobiLink\setup subdirectory of your SQL Anywhere installation. Before running the file, you must copy it to another location and modify it. Instructions follow.
In the MobiLink plug-in in Sybase Central, choose Mode > Admin and connect to your server database. Right-click the database name and choose Check MobiLink System Setup. If your database requires setup, you are prompted to continue.
When you use the Create Synchronization Model wizard or Deploy Synchronization Model wizard, system setup is checked when you connect to your server database. If your database requires setup, you are prompted to continue.
The database user who runs the setup script is the only user who will have permission to change the MobiLink system tables, which is required for configuring MobiLink applications.
To install MobiLink system tables using the setup script, an IBM DB2 UDB tablespace must use a minimum of 8 KB pages. If a tablespace does not use 8 KB pages, complete the following steps:
Verify that at least one of your buffer pools has 8 KB pages. If not, create a buffer pool with 8 KB pages.
Create a new tablespace and temporary tablespace that use the buffer pool with 8 KB pages.
For more information, consult your DB2 UDB documentation.
Customize syncdb2long.sql with your connection information:
Copy syncdb2long.sql to a new location where it can be modified and stored.
The syncdb2long.sql script contains a default connection statement,
connect to DB2Database. Alter this line to connect to your DB2 database. Use the following syntax:
connect to DB2Database user userid using password ~
where DB2Database, userid, and password are names you provide. (The syncdb2long.sql script uses the tilde character (~) as a command delimiter.)
db2 -c -ec -td~ +s -v -f syncdb2long.sql
Copy SyncDB2Long_1000.class and SyncDB2Long_1000.java, which are located in the MobiLink\setup subdirectory of your SQL Anywhere installation, to the FUNCTION subdirectory of your DB2 UDB installation.
You must set up an ODBC DSN for your DB2 consolidated database using the ODBC driver that is provided with your DB2 database. See:
Tablespace capacity A tablespace and temporary tablespace of any DB2 UDB database that you want to use as a consolidated database must use 8 KB pages.In addition, there are columns that require a LONG tablespace. If there is no default LONG tablespace, the creation statements for the tables containing these columns must be qualified appropriately, as in the following example:
CREATE TABLE ... ( ... ) IN tablespace LONG IN long-tablespaceFor an example using the sample application, see Exploring the CustDB Sample for MobiLink.
Session-wide variables DB2 UDB prior to version 8 does not support session-wide variables. A convenient solution is to use a base table with columns for the MobiLink user name and other session data. The base table has rows representing concurrent synchronizations.
User-defined procedures DB2 UDB prior to version 8.2 requires that you compile SQL procedures into an executable library (such as a DLL). The resulting DLL/shared library must be copied to a special directory on the server. Note that you can write procedures using several different languages, including C/C++ and Java, among others.For an example of Java as a procedural language for DB2 UDB, see the CustDB scripts in the files Samples\MobiLink\CustDB\custdbq.sql and Samples\MobiLink\CustDB\custdbq.java. For more information about Java and .NET synchronization scripts, see:
CHAR columns In IBM DB2 UDB, CHAR data types are fixed length and blank-padded to the full length of the string. In MobiLink remote databases (SQL Anywhere or UltraLite) CHAR is the same as VARCHAR: values are not blank-padded to a fixed width. It is strongly recommended that you use VARCHAR in the consolidated database rather than CHAR. If you must use CHAR, the mlsrv10 -b command line option can be used to remove trailing blanks from strings during synchronization. This option is important for string comparisons used to detect conflicts.See -b option.
Data type mapping The data types of columns must map correctly between your consolidated and remote database. For details, see IBM DB2 UDB data mapping.
Double up the quotation marks in system procedure calls When you use a MobiLink system procedure to add scripts to your DB2 consolidated database, you need to double up the quotation marks. For example, if the script you are adding with ml_add_table_script includes the line
SET "DELETED"=''Y'' for any other consolidated database, for DB2 you would have to write this as
SET "DELETED" = ''''Y''''.
Special considerations for version 5 and earlier If you are using IBM DB2 UDB prior to version 6, column names and other identifiers are only supported up to 18 characters. This means that you must truncate the names of MobiLink system procedures. For example, to call ml_add_connection_script, use the name ml_add_connection_.
See MobiLink isolation levels.