IMPORTANT PRE-REQUISITES
1. Set up environment to compile and run the sample application
The following script must be run for each of the terminal session:
Windows: > quickstart/ttquickstartenv.bat Unix/Linux: $ . quickstart/ttquickstartenv.sh OR
$ source quickstart/ttquickstartenv.csh2. Set up sample database, user accounts and the TPTBM table
The following command should be run once to set up the sample database, user accounts and the TPTBM table.
Windows or Unix/Linux: > cd quickstart/sample_code/j2ee_orm
> ttIsql -connStr "DSN=sampledb_1122" -f tptbm.sql3. If necessary, install the Apache Ant build tool.
For each application server, an Ant build script is provided to configure, build and execute the application based on the properties of the applicaton server installation. The Apache Ant build tool has to be installed if not present.
After installation, make sure the Operating System environment variable PATH includes the path to the 'ant' executable.
The Ant build scripts have been tested with Apache Ant version 1.9.2.
CONFIGURE AND RUN
1. install GlassFish application server and configure build.properties
Install GlassFish Server 3 and then set the following properties in file quickstart/sample_code/j2ee_orm/build.properties:
glassfish.home.dir -- set this to the root installation directory of the local GlassFish server installation glassfish.domain.dir -- the location of the domain directory for the server hosting the Tptbm application glassfish.deploy.dir -- the directory where application archives can be copied and auto deployed to the server glassfish.host -- the host name of the machine where the server is installed glassfish.orb.port -- the RMI port number used by external clients to communicate with the server, the default port number is 3700Each Ant build script reads values from file quickstart/sample_code/j2ee_orm/build.properties. This file specifies the locations of build dependencies including the location of the application server installation. This file also specifies the common benchmark execution parameters.2. TimesTen JDBC Driver
The server will require access to the TimesTen JDBC driver jar file. This can be done by copying the TimesTen JDBC driver jar file from the TimesTen installation's lib directory into the ${glassfish.domain.dir}/lib directory.
3. LD_LIBRARY_PATH
The server will also need access to the TimesTen shared libraries. This can be done by setting the LD_LIBRARY_PATH environment variable (or the equivalent variable for your OS) to the location of the TimesTen installation's lib directory. On Windows platforms the PATH environment variable should be set to the location of the installation's bin directory where TimesTen DLLs are located.
4. TimesTen Data Source
Before the application can be deployed or executed, a TimesTen connection pool and a JDBC data source with the JNDI name of jdbc/TbtbmDS must be configured on the server. Follow these steps:
- Connect to the GlassFish Server administration console. By default a local server's administration console can be accessed at http://localhost:4848.
- Select Resources->JDBC->Connection Pools from the left hand pane. Click the 'New...' button.
- At the 'New JDBC Connection Pool (Step 1 of 2)' screen enter 'TptbmPool' in the 'Name' field.
In the 'Resource Type' drop down list box select 'javax.sql.ConnectionPoolDataSource'.
In the 'Database Vendor' field enter 'Oracle TimesTen'. Click 'Next'.
- At the 'New JDBC Connection Pool (Step 2 of 2)' screen enter 'com.timesten.jdbc.ObservableConnectionDS' in the 'Datasource Classname' field.
Scroll down to the 'Additional Properties' section at the bottom of the screen.
Click the 'Add Property' button. A new row will appear.
Click the check box in the new row. Type 'url' in the 'Name' column. In the 'Value' column enter 'jdbc:timesten:direct:sampledb_1122'.
Click the check box for the 'password' property and in the 'Value' column type 'tiger'.
Click the check box for the 'user' property and in the 'Value' column type 'SCOTT'.
Click the 'Finish' button.
- Select Resources->JDBC->JDBC Resources from the left hand pane. Click the 'New...' button.
- At the 'New JDBC Resource' screen enter 'jdbc/TptbmDS' in the 'JNDI name' field. In the 'Pool Name' field select 'TptbmPool'. Click 'OK'.
- The server should be restarted in order for the configuration changes to take effect.
5. build, deploy and run the sample application
After the server has been configured to use the jdbc/TptbmDS data source and restarted, the application can be built, deployed, and executed, through Ant script build-glassfish3.xml, with this sequence of Ant tasks under directory quickstart/sample_code/j2ee_orm:
ant -f build-glassfish3.xml clean ant -f build-glassfish3.xml package ant -f build-glassfish3.xml deploy ant -f build-glassfish3.xml run
Note that this application has been tested with GlassFish Server 3.0.1, and GlassFish Server 3.1.2.2.
TROUBLESHOOTING
- Make sure the TimesTen binary bit version (32-bit or 64-bit) is the same as the bit version of the Java binary used to start GlassFish Server. Otherwise you may get a similar error as the following:
"Problems with loading native library/missing methods: D:\TimesTen\tt1122_32\bin\ttJdbc1122.dll : Can't find dependent libraries"
- If the following error pops up in the step of "ant -f build-glassfish3.xml run",
[java] Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Problems with loading native library/missing methods: no ttJdbc1122 in java.library.path
it is because the GlassFish server need access to the TimesTen shared libraries but env variables are not set correctly before launching the GlassFish server. Make sure the LD_LIBRARY_PATH includes the location of the TimesTen installation's lib directory. Or, on Windows platforms the PATH environment variable should include the location of the TimesTen installation's bin directory where TimesTen DDLs are located. (See step No.3 above).
For more information on Java programming with Oracle TimesTen, refer to the Oracle TimesTen In-Memory Database Java Developer's Guide.