How to Configure Oracle GlassFish Server 3.1.1

This section provides descriptions and examples of configuring the TimesTen JDBC driver for use with Oracle GlassFish Server 3.1.1.

Assumption: Oracle TimesTen and Oracle GlassFish Server have been successfully installed on the same host machine and that both instances are running.

Place the cursor over this icon to view images in this tutorial.

Configuring the TimesTen JDBC driver

Before you can use Oracle GlassFish Server to access the TimesTen databases, the GlassFish Server environment must have access to the TimesTen JDBC driver jar file and the TimesTen shared libraries. Here are the steps:

Step 1
Copy the TimesTen JDBC driver jar file (ttjdbc6.jar) from your TimesTen install directory <TimesTen_install_dir>/lib to <GlassFish_install_dir>/lib/ext directory, if the GlassFish Server is using JDK 1.6; otherwise, copy the TimesTen JDBC driver jar file (ttjdbc5.jar) if the GlassFish server is using JDK 1.5.

<TimesTen_install_dir> is the home directory where you installed Oracle TimesTen, and <GlassFish_install_dir> is the home directory where you installed the Oracle GlassFish Server.

Step 2
Set the LD_LIBRARY_PATH environment variable (or the equivalent variable for your OS) to include the TimesTen lib directory <TimesTen_install_dir>/lib.

On Windows, set the PATH environment variable to include the <TimesTen_install_dir>/bin directory where the TimesTen DLLs are located. The PATH variable must be set for the environment where the GlassFish Server runs.

Step 3
Restart the GlassFish Server for the changes to take effect.

Configuring TimesTen Connections and Connection Properties

The TimesTen JDBC driver supports four different types of connections to access the TimesTen database. The table below shows the connection types and the connection properties:

Direct-linked connections with local transactions only
This configuration is an in-process linked to the TimesTen database libraries; direct-linked connection provides the best response time for database operations and results in higher transaction throughput. To use this configuration, the GlassFish Server and the TimesTen database must be running in the same machine.

TimesTen Class: com.timesten.jdbc.ObservableConnectionDS

Example URL Property: jdbc:timesten:direct:sampledb_1122

Direct-linked connection with XA distributed transactions
The JDBC driver supports XA distributed transactions. For directed-link connections, the TimesTen database must reside on the same machine as the GlassFish Server. This connection type incurs distributed transaction overhead.

TimesTen Class: com.timesten.jdbc.xa.TimesTenXADataSource

Example URL Property: jdbc:timesten:direct:sampledb_1122

Client/server access with local transactions only
Client/Server connections are intended for applications not running in the same machine as the TimesTen database. Here, the GlassFish Server can access the TimesTen database from a remote machine. This connection mode incurs network (TCP/IP) overhead and is less responsive as the direct-linked connection mode.

TimesTen Class: com.timesten.jdbc.ObservableConnectionDS

Example URL Property: jdbc:timesten:client:sampledb_1122

Client/server access with XA distributed transactions
The JDBC driver supports XA distributed transactions. For client/server connections, the GlassFish Server may access the TimesTen database from a remote machine.This connection type incurs network overhead in addition to the distributed transaction overhead.

TimesTen Class: com.timesten.jdbc.xa.TimesTenXADataSource

Example URL Property: jdbc:timesten:client:sampledb_1122

 

Configuring a TimesTen JDBC Connection Pool

To configure a TimesTen JDBC connection pool in GlassFish Server, follow these steps:

1.
Connect to the GlassFish Server administration console
2.
Select Resources --> JDBC --> Connection Pools from the left hand pane
3.
Click New
4.

At the New JDBC Connection Pool (Step 1 of 2) screen enter a name for the new pool in the Name field. In the Database Vendor field enter Oracle TimesTen. In the Resource Type drop down list box select javax.sql.ConntionPoolDataSource if the application requires only local transactions; or select javax.sql.XADataSource if the application requires XA distributed transactions. See Figure 1 below.



Figure 1


5.

At the New JDBC Connection Pool (Step 2 of 2) screen enter com.timesten.jdbc.ObservableConnectionDS in the Datasource Classname field for local transactions. Enter com.timesten.jdbc.xa.TimesTenXADatasource if XA distributed transactions are required.



Figure 2

 

6.

Scroll down to the Additional Properties section at the bottom of the screen. Click Add Property. A new row will appear in the Properties section of the screen. Click the check box in the new row. Type url in the Name column. In the Value column enter the TimesTen URL for the database to which this pool should connect. A TimesTen URL takes the form jdbc:timesten:[direct|client]:DSN (refer to the section above for examples).



Figure 3

Click the check box for the user property and in the Value column enter the TimesTen user that this connection pool should connect as.

Click the check box for the password property and in the Value column enter the password for the TimesTen user.

The screen should look similar to Figure 3 above for a connection to a DSN named sampledb_1122 using appuser/appuser as the TimesTen user account.


Configuring a TimesTen JDBC Resource

In order for applications to access the timesTen connection pool, a JDBC resource must be created and associated with the pool. Follow these steps:

1.
Connect to the GlassFish Server administration console
2.
Select Resources --> JDBC --> JDBC Resources from the left hand pane.
3.
Click New
4.

At the New JDBC Resources screen, enter a JNDI name for the resource. In the Pool Name field, select the name of the TimesTen connection pool that was created in the previous steps. The dialog should look similar to Figure 4 below.



Figure 4

Click OK