JBoss.orgCommunity Documentation

Chapter 7. ODBC Support

7.1. Installing the ODBC Driver Client
7.1.1. Microsoft Windows
7.1.2. Other *nix Platform Installations
7.2. Configuring the Data Source Name (DSN)
7.2.1. Windows Installation
7.2.2. Other *nix Platform Installations
7.3. DSN Less Connection

Open DataBase Connectivity (ODBC) is a standard database access method developed by the SQL Access group in 1992. ODBC, just like JDBC in Java, allows consistent client access regardless of which database management system (DBMS) is handling the data. ODBC uses a driver to translate the application's data queries into commands that the DBMS understands. For this to work, both the application and the DBMS must be ODBC-compliant -- that is, the application must be capable of issuing ODBC commands and the DBMS must be capable of responding to them.

Teiid can provide ODBC access to deployed VDBs in the Teiid runtime through PostgreSQL's ODBC driver. This is possible because Teiid has specialized handling that allows it emulate a PostgreSQL server and respond appropriate to expected metadata queries.

Note

By default, ODBC on the Teiid is enabled and running on on port 35432.

Before an application can use ODBC, you must first install the ODBC driver on same machine that the application is running on and then create Data Source Name (DSN) that represents a connection profile for your Teiid VDB.

Warning

Teiid currently only supports plain text passward authentication for ODBC. If the client/server are not configured to use SSL, the password will be sent in plain text over the network. If you need secure passwords in transit and are not using SSL, then consider installing a security domain that will accept safe password values from the client (for example encrypted or hashed).

A PostgreSQL ODBC driver needed to make the ODBC connection to Teiid is not bundled with the Teiid distribution. The appropriate driver needs be downloaded directly from the PostgreSQL web site. We have tested with 8.04.200 version of the ODBC driver.

For all other platforms other than Microsoft Windows, the ODBC driver needs built from the source files provided. Download the ODBC driver source files from the PostgreSQL download site. Untar the files to a temporary location. For example: "~/tmp/pgodbc". Build and install the driver by running the commands below.

Note

You should use super user account or use "sudo" command for running the "make install" command.

                % tar -zxvf psqlodbc-xx.xx.xxxx.tar.gz
                % cd psqlodbc-xx.xx.xxxx
                % ./configure
                % make
                % make install
            

Some *nix distributions may already provide binary forms of the appropriate driver, which can be used as an alternative to building from source.

Once you have installed the ODBC Driver Client software on your workstation, you have to configure it to connect to a Teiid Runtime. Note that the following instructions are specific to the Microsoft Windows Platform.

To do this, you must have logged into the workstation with administrative rights, and you need to use the Control Panel’s Data Sources (ODBC) applet to add a new data source name.

Each data source name you configure can only access one VDB within a Teiid System. To make more than one VDB available, you need to configure more than one data source name.

Follow the below steps in creating a data source name (DSN)

  1. From the Start menu, select Settings > Control Panel.

  2. The Control Panel displays. Double click Administrative Tools.

  3. Then Double-click Data Sources (ODBC).

  4. The ODBC Data Source Administrator applet displays. Click the tab associated with the type of DSN you want to add.

  5. The Create New Data Source dialog box displays. In the Select a driver for which you want to set up a data source table, select PostgreSQL Unicode.

  6. Click Finish

  7. The PostgreSQL ODBC DSN Setup dialog box displays.


  8. In the Data Source Name edit box, type the name you want to assign to this data source.

    In the Database edit box, type the name of the virtual database you want to access through this data source.

    In the Server edit box, type the host name or IP address of your Teiid runtime. If connecting via a firewall or NAT address, the firewall address or NAT address should be entered.

    In the Port edit box, type the port number to which the Teiid System listens for ODBC requests. By default, Teiid listenes for ODBC requests on port 35432

    In the User Name and Password edit boxes, supply the user name and password for the Teiid runtime access.

    Provide any description about the data source in the Description field.

  9. Click on the Datasource button, you will see this below figure. Configure options as shown.


    Click on "page2" and make sure the options are selected as shown


  10. Click "save" and you can optionally click "test" to validate your connection if the Teiid is running.

You have configured a Teiid's virtual database as a data source for your ODBC applications. Now you can use applications such as Excel, Access to query the data in the VDB

Before you can access Teiid using ODBC on any *nix platforms, you need to either install a ODBC driver manager or verify that one already exists. As the ODBC Driver manager Teiid recommends unixODBC. If you are working with RedHat Linux or Fedora you can check the graphical "yum" installer to search, find and install unixODBC. Otherwise you can download the unixODBC manager here. To install, simply untar the contents of the file to a temporary location and execute the following commands as super user.

                ./configure
                make
                make install 
            

Check unixODBC website site for more information, if you run into any issues during the installation.

Now, to o verify that PostgreSQL driver installed correctly from earlier step, execute the following command

            odbcinst -q -d
            

That should show you all the ODBC drivers installed in your system. Now it is time to create a DSN. Edit "/etc/odbc.ini" file and add the following

                [<DSN name>]
                Driver = /usr/lib/psqlodbc.so
                Description = PostgreSQL Data Source
                Servername = <Teiid Host name or ip>
                Port = 35432 
                Protocol = 7.4-1
                UserName = <user-name> 
                Password = <password>
                Database = <vdb-name>
                ReadOnly = no
                ServerType = Postgres
                ConnSettings = 
                UseServerSidePrepare=1
                ByteaAsLongVarBinary=1
                Optimizer=0
                Ksqo=0
                Debug=0
                Fetch = 10000
                # enable below when dealing large resultsets
                #UseDeclareFetch=1                
            

Note that you need "sudo" permissions to edit the "/etc/odbc.ini" file. For all the available configurable options that you can use in defining a DSN can be found here on postgreSQL ODBC page.

Once you are done with defining the DSN, you can verify your DSN using the following command

                    isql <DSN-name> [<user-name> <password>] < commands.sql            
            

where "commands.sql" file contains the SQL commands you would like to execute.

You can also connect to Teiid VDB using ODBC with out explicitly creating a DSN. However, in these scenarios your application needs, what is called as "DSN less connection string". The below is a sample connection string

For Windows:

           ODBC;DRIVER={PostgreSQL Unicode};DATABASE=<vdb-name>;SERVER=<host-name>;PORT=<port>;Uid=<username>;Pwd=<password>            
        

>For *nix:

           ODBC;DRIVER={PostgreSQL};DATABASE=<vdb-name>;SERVER=<host-name>;PORT=<port>;Uid=<username>;Pwd=<password>