OpenLink UDBC SDK For Unix
binary.gif (2043 bytes)

What is UDBC?
Installation
Configuration
The Sample UDBC Application UDBCTEST.C
Example connect strings
Developing UDBC Applications
Further Reading


What is UDBC?

UDBC is OpenLink's acronym for Universal DataBase Connectivity.

In short, UDBC is the merge between the X/Open - SAG interface and the Microsoft ODBC interface for client database applications. UDBC was developed to enable software engineers to rapidly develop database independent applications without being concerned about issues like portability, network programming and database specific interfacing problems.

With UDBC it is possible to write database applications that are written according to the X/Open standard, but this SDK also provides access methods for the Microsoft ODBC programming interface.

Top


Installation

Move the following files to an installation directory of your choice (if such a directory does not exist, please create one):

  • Client .taz archive (in the format "xxkuzzzz.taz", where xx represents the operating system being used)
  • "install.sh"

From within the OpenLink base installation directory run the "install.sh" script :

sh install.sh

This will automatically extract the contents of the .taz file into the following sub-directory structure within your OpenLink base installation directory.

Files in the SDK
udbcsdk
udbcsdk/lib
udbcsdk/lib/libudbc.sl.1.5
udbcsdk/lib/libudbc.sl.1
udbcsdk/lib/libudbc.sl
udbcsdk/lib/libudbc.la
udbcsdk/lib/libudbc.a
udbcsdk/include
udbcsdk/include/udbc
udbcsdk/include/udbc/udbctype.h
udbcsdk/include/udbc/udbcodbc.h
udbcsdk/include/udbc/udbcsag.h
udbcsdk/include/udbc/udbcimpl.h
udbcsdk/include/udbc/udbcprto.h
udbcsdk/include/udbc/udbcext.h
udbcsdk/include/libudbc.h
udbcsdk/examples
udbcsdk/examples/udbctest.c
udbcsdk/examples/Makefile
udbcsdk/examples/udbctest
udbcsdk/doc
udbcsdk/doc/udbc.doc
udbcsdk/doc/udbc.ini

Top


Configuration

UDBC like ODBC is based on the notion of logical references to database backends through the use of Data Source Names, under UDBC these are described as Universal Data Source Names (UDSNs) due to the cross data access standard nature of these Data Source Names (they are usable by OpenLink Drivers for ODBC and JDBC™ ).

The OpenLink Data Access Driver Suite 1.5.5 requires you to manually create UDSNs by manually editing a designated file, and then creating your your UDSNs within this file (the OpenLink installer provides a template Universal Data Source Names file called "udbc.ini" - structured in exactly the same manner as a Windows "INI" configuration file). The OpenLink Data Access Driver Suite 3.2 on the other hand includes a HTML and HTTP based utility called the OpenLink "Web Configurator" that enables you create, configure, and manage UDSNs via any Web Browser.

You identify your UDSN file to UDBC Drivers via the Environment Variable "UDBCINI", if you do not set this variable OpenLink UDBC Drivers will use the template "udbc.ini" file that comes with your UDBC SDK installation. The UDBCINI environment variable is set using the command:

UDBCINI=/usr/openlink/bin/udbc.ini ; export UDBCINI

Note: The above presumes that your OpenLink installation's base directory is: /usr/openlink .

The example below depicts the structure of a UDSN named "dsn_oracle7", used to facilitate connections with an Oracle Database residing on a machine named "mercury".

[dsn_oracle7]
Database = ORCL
UserName = scott
Password = tiger
Host = mercury
ServerType = Oracle 7
FetchBufferSize = 60
Description = Oracle Database Connections


Your general OpenLink UDBC settings are configured within the "[UDBC]" section of your chosen UDSN file, an extract from this file is depicted below:

[UDBC]
;DebugFile = /tmp/udbc.out ; Write client debugging output

[Communications]
ReceiveTimeout = 120 ; max. time to complete a request
BrokerTimeout = 30 ; max. time to wait for oplrqb
RetryTimeout = 5 ; Retry time for oplrqb locating
SendSize = 4096 ; RPC send buffer size
ReceiveSize = 16000 ; RPC receive buffer size
ShowErrors = Y ; Pass RPC errors to applications
DataEncryption = N ; Encrypt outgoing data

Note: It is highly recommended that you use the UDSN templates provided by your OpenLink UDBC SDK installation for your initial connection, as the OpenLink installer sets up the appropriate UDBC environment for you at installation time.

The table below describes each OpenLink UDBC attribute required for making a connection from your UDBC based application to your backend database engine.

Section and Keys Default Value Corresponding Connect String option Description
[UDBC Global]     Global UDBC client communications settings.
BrokerTimeout 30   The time (in secs) that the client application will wait for the request broker (oplrqb) to accept or reject a database connection.
ReceiveTimeout 60   The time (in secs) that the client application will wait for a database agent to finish a request.
PortMapTimeout 30   When using the ONC portmap or rpcbind name services, this is the time (in secs) that the client application will wait for a reply from the portmapper.
SendSize 4096   RPC send buffer size. A value of 0 will cause the application to use the default value.
ReceiveSize 16000   RPC receive buffer size. A value of 0 will cause the application to use the default value.
DebugFile no debugging   When this variable contains a valid filename, the client applications will write debugging information to that file. Do not use this in the systemwide ini file! (/etc/udbc.ini) This file will contain detailed UDBC call tracing.
[DSN_name]   DSN=DSN_name Name of the Data Source
Host   HOST=name Name of host to contact (hostname or network address)
ServerType   SVT=type Specify agent domain This is used by the broker to determine which agent section to connect the client request to using mapping rules.
ServerOptions     Server startup options specific to agent/database.
Database   DATABASE=db Database to use. Agent/database specific.
Options   OPTIONS=opts Database connect options. Agent/database specific.
UserName   UID=username Username to connect as.
    PWD=password Password for user.
ReadOnly   READONLY=<y|n> Specify Y(es) for read-only (ro) or N(o) for read-write (rw) connections. Read only connections are sometimes faster, but can never modify any database.
FetchBufferSize 5 FBS=<value> Number of rows (records) to be fetched per call from database agent. Values range from 1 to 99


UDBC Client to Server Mechanics

When connecting to a database, the application sends the UDBC engine a connect string that contains the necessary parameters to complete the database connection.

When the connect string is empty, or a null pointer, the [Default] section is used for the remaining connect parameters.

When the connect string contains a "DSN=<name>" setting, then the section [name] (case insensitive) will be picked from the "udbc.ini" file in use.

All other settings in the connect string overrule the values in the udbc.ini file when supplied.

Note: the OpenLink "Session Rules" Book will determine the ultimate database destination of your UDBC Driver.

Top


Example UDBC Connect Strings:

"" (empty)

Use the values from the [Default] section. There must be at least a Host= definition in that section.

"DSN=dsn_Oracle7"

Use the values from the [dsn_Oracle7] section.

"DSN=dsn_Oracle7;UID=scott;PWD=tiger"

Use the values from the [dsn_Oracle7] section, and overrides the value for UserName. Also use the password "tiger" to gain access to the database.

"HOST=mercury;SVT=Oracle 7;DATABASE=ORCL;UID=scott/tiger"

Connect to an Oracle 7 database on the machine "mercury" .

"READONLY=Y"

Make a read-only connection to the [Default] database.

Top


The Sample UDBC Application "UDBCTEST"

Your OpenLink UDBC SDK installation contains a sample interactive dynamic SQL application called "udbctest", this application is situated within your OpenLink installation's "udbcsdk/examples" sub-directory.

Then run the application by typing the following command from the command line prompt:

      udbctest or ./udbctest

The application will prompt you for a connect string (assuming we are using the UDSN example depicted above):

         Enter UDBC connect string: DSN=generic_Oracle7

If you connect to the database successfully you will get a SQL prompt:

      SQL>

Type a valid SQL statement and then press <return> to send your request to your UDSN

      SQL> select * from <table name>
or Use an OpenLink quick table list command:
SQL> tables

If the query returns data and was successful, the data will be scrolled down the screen.

Otherwise you will receive an error message.

Type in "exit" to quit the application


Compiling Sample Program

To compile the application type the following command from the command line :

      make -f udbctest.mk

Top


Developing UDBC Applications

This UDBC SDK only implements an interface for the 'C' programming language.

To write an UDBC application,you must perform the following tasks::

a. include the file "libudbc.h" in your 'C' program(s)

b. link the application with the "libudbc.a" and the "librpc.a" libraries.

Note: Some UNIX systems also need -lsocket, -lnsl_s or both.

Top


Further Reading:

"Data Management: SQL Call Level Interface (CLI)"

from X/Open in conjunction with SQL Access Group

ISBN: 1-872630-63-4

X/Open Document Number: S203

Microsoft ODBC API documentation

 

Top