Omnis Technical Note TNSQ0016 June 2009

Connecting to Sybase SQL Anywhere 10/11 from a Mac-Intel Client

For Omnis Studio 4.2/4.3 and 5.0
By Gary Ashford

This technote discusses how to connect to an instance of Sybase SQL Anywhere 10 or 11 server via ODBC from a Mac-Intel/OSX client machine.

If you are using SQL Anywhere 9, you may want to refer to Tech Note TNSQ0008 instead.
If you are using SQL Anywhere 11, please also refer to the addendum at the end of this page.

The Problem
Using the SQL Anywhere 10 ODBC driver: dbodbc10_r.bundle (or dylib) supplied with SQL Anywhere, it is not possible to connect to an instance of SQLAnywhere either running locally or on the network. Using the SQL Browser, you typically you see an error message similar to:

This occurs because the SQL Anywehere driver is not compatible with the standard Apple/Openlink ODBC administrator library. Instead, it is designed to used solely in conjunction with the SQL Anywhere ODBC administrator library: libdbodm10.dylib.

The Solution
To remedy this issue, it is necessary to use an ODBC DAM which is linked against the SQLiAnywhere ODBC administrator library: libdbodm10.dylib. This replacement DAM is available from our Tools & Updates page.

SQL Anywhere ODBC DAM
 

You can use this DAM to connect to an instance of SQL Anywhere 10 or 11 running on the same machine or across the network- referring to the required instance using the ServerName key of the ODBC datasource.
For example, to connect to a local instance:
 

[ODBC Data Sources]           
SybaseSA       = Sybase SQL Anywhere Driver


[SybaseSA]
Driver=/Applications/SQLAnywhere10/System/lib32/libdbodbc10_r.dylib
UID=dba
PWD=sql
ServerName=demo
CommLinks=tcpip
(excerpt from odbc.ini file)

To connect to a remote instance:
 

[ODBC Data Sources]           
SybaseSA       = Sybase SQL Anywhere Driver


[SybaseSA]
Driver=/Applications/SQLAnywhere10/System/lib32/libdbodbc10_r.dylib
UID=dba
PWD=sql
ServerName=demo
CommLinks=tcpip(HOST=192.168.0.1;PORT=2638)
(excerpt from odbc.ini file)

Notes.

 The SQL Anywhere ODBC administrator library will not be on the standard library search path by default. Please refer to Technote TNSQ0025 which describes use of the DYLD_LIBRARY_PATH variable for locating dynamic libraries.
Please note that DYLD_LIBRARY_PATH must point to the folder containing the ODBC driver you will be using. This is because the ODBC driver has dependencies on other dynamic libraries found in this folder, as indicated below.

 The SQL Anywhere ODBC library cannot be used to connect to standard ODBC data sources. Thus, it is advisable to store a backup of your original ODBC DAM to be restored later if required. (Do not rename the DAM and leave it in the XCOMP folder or attempt to use both DAMs- as this will cause a conflict).
 
 You can store the SQL Anywhere datasource information in the same odbc.ini file used by the Apple/Openlink ODBC Administrator. Remember to edit the damodbc.ini file inside the Omnis:xcomp:ini folder and set the ODBCINI environment variable to point to your odbc.ini file if required. For example,

ODBCINI=/Library/ODBC/odbc.ini

 Please refer to the readme file which accompanies the SQL Anywhere DAM for specific changes and behavioural differences that are relevant to this DAM. In particular, the new ODBC Administration features provided by the standard ODBC DAM are not provided by libdbodm10.dylib. Hence these methods have no effect in the SQL Anywhere DAM.

 Ensure that Omnis is not set to run in Rosetta mode. (See Tech Note TNSQ0011).
Both the iAnywhere ODBC adminstration library and the SQL Anywhere ODBC driver are built with Intel only architecture. Hence the DAM will not load in PPC emulation mode (or if the native architecture is not Intel).

 The SQL Anywhere ODBC administrator does not have a graphical tool for editing data sources. You can edit your odbc.ini file manually (as shown above). Alternatively, SQL Anywhere provides a dbdsn utility (in the SQLAnywhere/System/bin32 folder) which can be used to add and show data source information.

 You cannot use the SQL Anywhere 11 ODBC driver with the non-Unicode version of Omnis Studio 4.2/4.3.
Please refer to the troubleshooting section below for details.
 
ODBC Driver Required Files
Should you wish to connect remotely to a SQL Anywhere server and do not want to install the full server on each client machine, you will need to obtain the following files from an OSX server installation. These files are all dependencies of the dbodbc10_r.bundle (the multi-threaded driver) and should also be present on the DYLD_LIBRARY_PATH search path:

dbodbc10_r.bundle
libdbodbc10.dylib
libdbodbc10_r.dylib
libdbodm10.dylib
libdbtasks10.dylib
libdbtasks10_r.dylib
libdbicu10.dylib
libdbicu10_r.dylib
libdbicudt10.dylib
dblg[en]10.res

Using the SQL Anywhere ODBC DAM with SQL Anywhere 11
Please note that the libraries supplied with SQL Anywhere 11 are named differently to those supplied with SQL Anywhere 10. For example, the ODBC driver file is named "libdbodbc11_r.dylib" instead of "libdbodbc10_r.dylib" and the ODBC Administration library is named "libdbodm11.dylib" instead of " libdbodm10.dylib".
For this reason it is necessary to create a symbolic link using a terminal window as follows:

$ cd /Applications/SQLAnywhere11/System/lib32
$ ln -s libdbodm11.dylib libdbodm10.dylib

This is necessary because the SQL Anywhere ODBC DAM is linked against libdbodm10.dylib.
 
If you want to use the SQL Anywhere 11 ODBC driver in place of the SQL Anywhere 10 driver, the ODBC data source will need to be setup to point to the SQL Anywhere 11 driver. For example:

Driver=/Applications/SQLAnywhere10/System/lib32/libdbodbc10_r.dylib
  becomes
Driver=/Applications/SQLAnywhere11/System/lib32/libdbodbc11_r.dylib

The DYLD_LIBRARY_PATH variable should also be set differently:

/Applications/SQLAnywhere10/System/lib32
  becomes
/Applications/SQLAnywhere11/System/lib32

Please note however that the SQL Anywhere 10 ODBC driver is compatible with SQL Anywhere 11.

Troubleshooting
If you encounter a logon error stating, "Data Source name not found and no default driver specified",this can indicate that:

  • ODBCINI has not been set correctly, (i.e. to "/Library/ODBC/odbc.ini" ).
    Edit the xcomp/ini/odbcdam.ini file and re-try the logon.
  • The value of ODBCINI was set in the environment.plist file but has been overridden by the value set in the xcomp/ini/odbcdam.ini file. Remove the odbcdam.ini file and re-try the logon.
  • You have specified dbodbc10_r.bundle as the ODBC driver name.
    Try specifying libdbodbc10_r.dylib instead, which should prompt the ODBC administration library to detect the data source.

  • You are attempting to connect to SQL Anywhere 11 using libdbodbc11_r.dylib and the non-Unicode version of Omnis Studio. Please note that the SQL Anywhere 11 ODBC components support Unicode only.
    To connect to SQL Anywhere 11, please retain and use the SQL Anywhere 10 driver.

If you encounter a logon error stating, "Database Server not found ", this can indicate that:

  • The SQL Anywhere database has not been started or is not listening on the specified port or at the specified IP address.
  • The ServerName DSN parameter contains a space character after the equals sign, e.g. ServerName = demo In this instance, SQL Anywhere mistakes the space character as the first character of the database name. Edit the odbc.ini file to remove the space character, then re-start Studio.

References
Creating an ODBC datasource for use with dbodbc10_r.bundle: http://www.ianywhere.com/developer/product_manuals/sqlanywhere/1001/en/html/dbdaen10/da-connect-s-3731160.html
ODBC Driver required files: http://www.ianywhere.com/developer/product_manuals/sqlanywhere/1001/en/html/dbpgen10/pg-odbc-driver-deploy.html
Sybase SQL Anywhere platform compatibility:
http://www.versiontracker.com/dyn/moreinfo/macosx/20041
Setting Environment Variables on the Mac: TNSQ0025