Collection Contents Index JDBC-based server classes PART 5.  The Adaptive Server Family pdf/chap29.pdf

User's Guide
   PART 4. Database Administration and Advanced Use
     CHAPTER 29. Server Classes for Remote Data Access       

ODBC-based server classes


The ODBC-based server classes are:

Top of page  Defining ODBC external servers

For Info    The most common way of defining an ODBC-based server is to base it on an ODBC data source. To do this, you must create a data source in the ODBC Administrator.

Once you have the data source defined, the USING clause in the CREATE SERVER statement should match the ODBC data source name.

For example, to configure a DB2 server named mydb2 whose Data Source Name is also mydb2, use:

CREATE SERVER mydb2 
CLASS 'db2odbc' 
USING 'mydb2'

For Info     For more information on creating data sources, see Creating an ODBC data source.

Using connection strings instead of data sources 

An alternative, which avoids using data sources, is to supply a connection string in the USING clause of the CREATE SERVER statement.

To do this, you must know the connection parameters for the ODBC driver you are using. For example, a connection to an ASA may be as follows:

CREATE SERVER testasa 
CLASS 'asaodbc'
USING 'driver=adaptive server anywhere 6.0;eng=testasa;dbn=sample;links=tcpip{}'

This defines a connection to an Adaptive Server Anywhere database server named testasa, database sample, and using the TCP-IP protocol.

See also 

For information specific to particular ODBC server classes, see:

Top of page  Server class asaodbc

A server with server class asaodbc is:

No special requirements exist for the configuration of an Adaptive Server Anywhere data source.

The ODBC driver for version 6 databases is installed when you install Adaptive Server Anywhere. To access version 5 servers, install the version 5 ODBC driver. You cannot use the version 6 ODBC driver to connect to a version 5 Adaptive Server Anywhere.

To access Adaptive Server Anywhere servers that support multiple databases, create an ODBC data source name defining a connection to each database. Issue a CREATE SERVER statement for each of these ODBC data source names.

Top of page  Server class aseodbc

A server with server class aseodbc is:

Adaptive Server Anywhere requires the installation of the Adaptive Server Enterprise ODBC driver and Open Client connectivity libraries to connect to a remote Adaptive Server with class aseodbc. However, the performance is better than with the asejdbc class.

Notes 

Top of page  Data type conversions

When you issue a CREATE TABLE statement, Adaptive Server Anywhere automatically converts the data types to the corresponding Adaptive Server Enterprise data types. The following table describes the Adaptive Server Anywhere to Adaptive Server Enterprise data type conversions.

Adaptive Server Anywhere data type

Adaptive Server Enterprise default data type

bit

bit

tinyint

tinyint

smallint

smallint

int

int

integer

integer

decimal [defaults p=30, s=6]

numeric(30,6)

decimal(128,128)

not supported

numeric [defaults p=30 s=6]

numeric(30,6)

numeric(128,128)

not supported

float

real

real

real

double

float

smallmoney

numeric(10,4)

money

numeric(19,4)

date

datetime

time

datetime

timestamp

datetime

smalldatetime

datetime

datetime

datetime

char(n)

varchar(n)

character(n)

varchar(n)

varchar(n)

varchar(n)

character varying(n)

varchar(n)

long varchar

text

text

text

binary(n)

binary(n)

long binary

image

image

image

bigint

numeric(20,0)

Top of page  Server class db2odbc

A server with server class db2odbc is:

Notes 

Top of page  Data type conversions

When you issue a CREATE TABLE statement, Adaptive Server Anywhere automatically converts the data types to the corresponding DB2 data types. The following table describes the Adaptive Server Anywhere to DB2 data type conversions.

Adaptive Server Anywhere data type

DB2 default data type

bit

smallint

tinyint

smallint

smallint

smallint

int

int

integer

int

bigint

decimal(20,0)

char(1-254)

varchar(n)

char(255-4000)

varchar(n)

char(4001-32767)

long varchar

character(1-254)

varchar(n)

character(255-4000)

varchar(n)

character(4001-32767)

long varchar

varchar(1-4000)

varchar(n)

varchar(4001-32767)

long varchar

character varying(1-4000)

varchar(n)

character varying(4001-32767)

long varchar

long varchar

long varchar

text

long varchar

binary(1-4000)

varchar for bit data

binary(4001-32767)

long varchar for bit data

long binary

long varchar for bit data

image

long varchar for bit data

decimal [defaults p=30, s=6]

decimal(30,6)

numeric [defaults p=30 s=6]

decimal(30,6)

decimal(128, 128)

NOT SUPPORTED

numeric(128, 128)

NOT SUPPORTED

real

real

float

float

double

float

smallmoney

decimal(10,4)

money

decimal(19,4)

date

date

time

time

smalldatetime

timestamp

datetime

timestamp

timestamp

timestamp

Top of page  Server class oraodbc

A server with server class oraodbc is:

Notes 

Top of page  Data type conversions

When you issue a CREATE TABLE statement, Adaptive Server Anywhere automatically converts the data types to the corresponding Oracle data types. The following table describes the Adaptive Server Anywhere to Oracle data type conversions.

Adaptive Server Anywhere data type

Oracle data type

bit

number(1,0)

tinyint

number(3,0)

smallint

number(5,0)

int

number(11,0)

bigint

number(20,0)

decimal(prec, scale)

number(prec, scale)

numeric(prec, scale)

number(prec, scale)

float

float

real

real

smallmoney

numeric(13,4)

money

number(19,4)

date

date

time

date

timestamp

date

smalldatetime

date

datetime

date

char(n)

if (n > 255) long;

else varchar(n)

varchar(n)

if (n > 2000) long;

else varchar(n)

longchar

long

binary(n)

if (n > 255) long raw

else raw(n)

varbinary(n)

if (n > 255) long raw

else raw(n)

longbinary

long raw

Top of page  Server class mssodbc

A server with server class mssodbc is:

Notes 

Top of page  Data type conversions

When you issue a CREATE TABLE statement, Adaptive Server Anywhere automatically converts the data types to the corresponding Microsoft SQL Server data types. The following table describes the Adaptive Server Anywhere to Microsoft SQL Server data type conversions.

Adaptive Server Anywhere Data type

Microsoft SQL Server Default Data type

bit

bit

tinyint

tinyint

smallint

smallint

int

int

bigint

numeric(20,0)

decimal [defaults p=30, s=6]

decimal(prec, scale)

numeric [defaults p=30 s=6]

numeric(prec, scale)

float

if (prec) float(prec) else float

real

real

smallmoney

smallmoney

money

money

date

datetime

time

datetime

timestamp

datetime

smalldatetime

datetime

datetime

datetime

char(n)

if (length > 255) text else varchar(length)

character(n)

char(n)

varchar(n)

if (length > 255) text else varchar(length)

longchar

text

binary(n)

if (length > 255) image else binary(length)

long binary

image

double

float

Top of page  Server class odbc

Server class odbc is used for ODBC data sources that do not have their own server class. Any ODBC driver that complies with ODBC version 2.0 compliance level 1 or higher can be used. Sybase certifies the following ODBC data sources:

The latest versions of Microsoft ODBC drivers can be obtained through the Microsoft Data Access Components (MDAC) distribution found at www.microsoft/data/download.htm. The Microsoft driver versions listed below are part of MDAC 2.0.

The following sections provide notes on accessing these data sources.

Top of page  Microsoft Excel (Microsoft 3.51.171300)

With Excel, each Excel workbook is logically considered to be a database holding several tables. Tables are mapped to sheets in a workbook. When you configure an ODBC data source name in the ODBC driver manager, you specify a default workbook name associated with that data source, however when you issue a CREATE TABLE statement, you can override the default and specify a workbook name in the location string. This allows you to use a single ODBC DSN to access all of your excel workbooks.

In this example, an ODBC data source named excel was created. To create a workbook named work1.xls with a sheet (table) called mywork:

CREATE TABLE mywork (a int, b char(20)) 
AT'excel;d:\work1.xls;;mywork'

To create a second sheet (or table) execute a statement such as:

CREATE TABLE mywork2 (x float, y int) 
AT 'excel;d:\work1.xls;;mywork2'

Existing worksheets can be imported into Adaptive Server Anywhere using CREATE EXISTING. It is expected that the first row of your spreadsheet contains column names.

CREATE EXISTING TABLE mywork 
AT'excel;d:\work1;;mywork'

If Adaptive Server Anywhere reports that the table is not found, you may need to explicitly state the column and row range that you wish to map to. For example:

CREATE EXISTING TABLE mywork 
AT 'excel;d:\work1;;mywork$'

Adding the $ to the sheet name indicates that the entire worksheet should be selected.

Note in the location string specified by AT that a semicolon is used instead of a period for field separators This is because periods occur in the file names. Excel does not support the owner name field so leave this blank.

Deletes are not supported. Also some updates may not be possible since the Excel driver does not support positioned updates.

Top of page  Microsoft Access (Microsoft 3.51.171300)

Access databases are stored in a .mdb file. Using the ODBC manager, create an ODBC data source and map it to one of these files. A new .mdb file can be created through the ODBC manager. This database file will be used as the default if one is not specified when you create a table through Adaptive Server Anywhere.

Assuming an ODBC data source named access.

CREATE TABLE tab1 (a int, b char(10)) 
AT 'access...tab1'

or

CREATE TABLE tab1 (a int, b char(10)) 
AT 'access;d:\pcdb\data.mdb;;tab1'

or

CREATE EXISTING TABLE tab1 
AT 'access;d:\pcdb\data.mdb;;tab1'

Access does not support the owner name qualification, leave it empty.

Top of page  Microsoft Foxpro (Microsoft 3.51.171300)

Foxpro tables can be stored together inside a single foxpro database file (.dbc) or each table can be stored in its own separate .dbf file. When using .dbf files, be sure the file name is filled into the location string, otherwise the directory that Adaptive Server Anywhere was started in will be used.

CREATE TABLE fox1 (a int, b char(20)) 
AT 'foxpro;d:\pcdb;;fox1'

This statement will create a file named d:\pcdb\fox1.dbf when the "free table directory" option is chosen in the odbc driver manager.

Top of page  Lotus Notes SQL 2.0 (2.04.0203))

This driver can be obtained from the .

Read the documentation that comes with this driver for an explanation of how Notes data is mapped to relational tables. You can easily map Adaptive Server Anywhere tables to Notes forms.

Here is how to set up Adaptive Server Anywhere to access the Address sample file.

Avoiding password prompts 

Lotus Notes does not support sending a user name and password through the ODBC API. If you try to access Lotus notes using a password protected ID, a window appears on the machine where Adaptive Server Anywhere is running prompting you for a password. This behavior is not desirable for a multi-user server.

To access Lotus Notes unattended, without ever receiving a password prompt, you must use a non-password-protected ID. You can remove password protection from your ID by clearing it (File->Tools->User ID->Clear Password), unless your Domino administrator required a password to be used when your ID was created. In this case, you will not be able to clear it.

Top of page  

Collection Contents Index JDBC-based server classes PART 5.  The Adaptive Server Family pdf/chap29.pdf