Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 6 Using TIBCO Object Service Broker Adapter for JDBC-ODBC : Accessing TIBCO Object Service Broker Using JDBC

Accessing TIBCO Object Service Broker Using JDBC
Overview of JDBC support
The TIBCO Object Service Broker JDBC-ODBC Adapter provides JDBC access to any Java-enabled applet, application, or application server. JDBC supports interfaces for querying and updating data and running stored procedures in a database. The JDBC driver for TIBCO Object Service Broker Adapter for JDBC-ODBC is a type 4 driver and is compliant with the JDBC 3.0 specification.
The Adapter is implemented by a 3-tier architecture. Your Java application uses a "thin" JDBC driver to access TIBCO Object Server Broker tables and rules. The "thin" client communicates via TCP/IP with a SQL service which processes SQL requests and handles joins. The SQL service runs only on Open Systems and uses the TIBCO Object Server Broker SDK for Java to access and modify Object Service Broker table data.
Running the SQL Service
To use the JDBC client driver you must first start the SQL Service.
On Windows the Service is installed as a Windows Service and can be automatically started each time you reboot your machine.
On UNIX use the script files startservices.sh and stopservices.sh in the directory jcbc/service/admin to start and stop the SQL Services. The services run as daemon processes, so you can close the terminal window after starting the services without terminating the services.
A UNIX system administrator can use these scripts to change system start-up so that the SQL services automatically are started and stopped each time a system is booted and shutdown. Similar scripts are available for a Windows installation.
The services report problems in log files located in the directory jdbc/service/logging. When running production systems, you should periodically clear these directories of old log files.
Setting the CLASSPATH
The JDBC Client must be included in your CLASSPATH variable. The CLASSPATH is the search string your Java Virtual Machine (JVM) uses to locate the JDBC driver on your computer. If it is not defined on your CLASSPATH, you will receive a "class not found" error when trying to load the JDBC Client. You can find the driver jar file, oajc.jar, in the jdbc/client directory of your TIBCO Object Service Broker JDBC Adapter install.
Registering the JDBC Client
To use the JDBC Client, you first must register it with the JDBC Driver Manager. That can be accomplished in one of three ways:
1.
Set the Java property jdbc.drivers using the Java -D option. The jdbc.drivers property is defined as a colon-separated list of driver class names. For example:
java -Djdbc.drivers=com.ddtek.jdbc.openaccess.OpenAccessDriver
2.
Set the Java property jdbc.drivers from within your Java application or applet. To do this, include the following code in your application or applet, and call DriverManager.getConnection():
Properties p = System.getProperties();
p.put ("jdbc.drivers", "com.ddtek.jdbc.openaccess.OpenAccessDriver");
System.setProperties (p);
3.
Explicitly load the driver class using the standard Class.forName() method. To do this, include the following code in your application or applet and call:
DriverManager.getConnection(): Class.forName("com.ddtek.jdbc.openaccess.OpenAccessDriver");
Specifying the JDBC Driver Connection URLs
When creating a JDBC connection you need to specify a connection URL that includes Adapter SQL Service connection information and TIBCO Object Service Broker parameters. A connection URL for the TIBCO Object Service Broker JDBC driver follows the following format:
jdbc:openaccess://hostname:port;ServerDataSource=OSB;CustomProperties=(key=value;...)
where:
hostname is the name of the host or the IP address where the SQL Service is running. If the JDBC driver is running on the same machine where the Adaptor SQL Service is running then LOCALHOST will suffice.
port is the TCP/IP port on which the SQL Server is listening. A default installation of the SQL Server uses the port 19988.
ServerDataSource must be set to OSB.
CustomProperties is set to the connection parameter required to connect to your Object Service Broker Execution Environment.
Note that JDBC URL parameters are separated by semicolons.
The following keywords are supported in CustomProperties JDBC parameter and are the same properties supported by the Object Service Broker ODBC Adapter:
 
is the reference to the machine where the Execution Environment (osMon in case of Windows/Solaris; Native/CICS Execution Environment in case of z/OS) is running ("localhost" if connecting locally). This parameter must be specified with PORT, if NODE is not specified but cannot be used with NODE.
is the port number defined for the Execution Environment denoted by HOST. This parameter must be specified with HOST, if NODE is not specified but cannot be used with NODE.
is a node name entry in the huron.dir file that describes the TIBCO Object Service Broker nodes available for connections. This parameter cannot be used with HOST or PORT. It must be specified if HOST and PORT are not specified.
[optional] is the user ID for connecting to TIBCO Object Service Broker. If not available OSBUID defaults to the value, if any, in the respective section of the session.prm file.
[optional] is the user password corresponding to OSBUID. If OSBPWD defaults to the value, if any, in the respective section of the session.prm file.
DEFAULT means that the TIBCO Object Service Broker session's BROWSE attribute is set to the value, if any, in the respective section of the session.prm file.
OSBUNIT0, OSBUNIT1, OSBUNIT2, OSBUNIT3, OSBUNIT4
[optional] "Y" or "y" for TRUE; any other value stands for FALSE. Determines whether fixed-length character (CHAR) fields should be right- blank-padded by TIBCO Object Service
Using Stored Procedures
Object Service Broker Rules can be called as stored procedure through the JDBC driver. Such Rules must be pre-registered in TIBCO Object Service Broker's persistent table @IP_PROCS. Java client code can use the CallableStatement JDBC interface object to pass parameters and execute Rules. Please refer to the "Using TIBCO Object Service Broker ODBC Adapter" chapter and review the "Designating TIBCO Object Service Broker Rules as ODBC Stored Procedures" and the "Writing TIBCO Object Service Broker Rules as ODBC Stored Procedures" sections for more information about defining a stored procedure in the TIBCO Object Service Broker. Also review the stored procedure sample in the jdbc/samples directory.
 
 

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved