Version 6

    WARNING this article is out of date - please refer to more recent documentation.

     

    After the Teiid runtime is installed and started in the "Server" mode,  client applications can connect to Teiid Server and issue SQL queries against deployed VDBs using Teiid's JDBC connection. You can configure it as a JDBC data source, if you are using an application server such as JBoss AS. If you are new to JDBC, learn more about JDBC here.

     

    Teiid comes with the "teiid-{version}-client.jar" file in the "<teiid-install>/client" directory. It contains the Java library files necessary to make JDBC connections. Teiid provides multiple ways to create JDBC connections:

     

    1. TeiidDriver - To make the JDBC connections using DriverManager class.
    2. TeiidDatasource - Make JDBC connections using DataSource class. You can use this to create JDBC XA connections.

     

    Driver Based Connection

    Add the above jar file in your application's class path and use "org.teiid.jdbc.TeiidDriver" as the driver class.  Use the following URL format for JDBC connections:

     

    jdbc:teiid:<vdb-name>@mm[s]://<host>:<port>;[prop-name=prop-value;]*

     

    where

        <vdb-name> - Name of the VDB you are connecting to

         mm - defines Teiid JDBC protocol, mms defines a secure channel (see how to turn on SSL)

        <host> - defines the server where the Teiid Server is installed

        <port> - defines the port on which the Teiid Server is listening for incoming JDBC connections.

        [prop-name=prop-value] - addtionally you can supply any number of name value pairs separated by semi-colon [;], further refining the connection. All supported URL properties are defined here.

     

    Sample Code:

        public class Teiid {
            public Connection getConnection(String user, String password) throws Exception {
                String url = "jdbc:teiid:myVDB@mm://localhost:31000;ApplicationName=myApp";
                Class.forName("org.teiid.jdbc.TeiidDriver");
                return DriverManager.getConnection(url, user, password);
            }
        }

     

     

    Datasource Based Connection

     

    To use a data source based connection use "org.teiid.jdbc.TeiidDataSource" as the data source class. If your JDBC connection needs to participate in an XA transaction, you must use the data source connection. This data source is XA capable.

     

    Sample Code:

     

        public class Teiid {
            public Connection getConnection(String user, String password) throws Exception {
                TeiidDataSource ds = new TeiidDataSource();
                ds.setUser(user);
                ds.setPassword(password);
                ds.setServerName("localhost");
                ds.setPortNumber(31000);
                ds.setDatabaseName("myVDB");
                return ds.getConnection();
            }
        }
    
    
    

     

    All the Teiid Data Source supported  properties  are defined here.

     

    Note: Teiid will support the XA protocol, if all sources that Teiid is integrating also support XA and are configured as XA. If one or more sources are not XA capable, they can be marked as read-only and still participate in an XA transaction with the remaining sources.


    If you are interested in deploying Teiid as a data source in JBoss AS follow the directions here.