This chapter describes how to integrate ALTIBASE and TOMCAT.
There are two methods to integrate: using DBCP (regular JDBC) or using ALTIBASE ConnecitonPool.
JNDI DataSource Integration
To configure JNDI DataSource, write the following in $CATALINA_HOME/conf/context.xml.
It can be used on the web by adding the following contents to the web application home/WEB-INF/web.xml.
Web application home/WEB-INF/web.xml
The properties defined in the tag are as follows.
Altibase JDBC driver class Name
|The connection string information for connecting with ALTIBASe. Enters jdbc:Altibase://IP:port_no/db_name"|
|The database account|
The database password
|The maximum number of connections, 0 is unlimited. The default is 8.|
|The initial size of connections. The default is 0.|
|The maximum number of connections that wait in the pool. The default is 8.|
|The minimum number of connections that wait in the pool. The default is 0.|
The maximum connection attempt time (unit: millisec) -1 waits indefinitely. The default: infinite waiting.
The SQL statement used to check the validation of connection
Must be specified as a select statement that returns at least one row
Ex) select 1 from dual
Sets autocommit mode. The default: true.
Sets Transaction Isolation level.
The values of REPEATABLE_READ, SERIALIZABLE, and the default can be set, and the default follows the default value of the DB server.
The isolation level of ALTIBASE is READ COMMITED by default.
Determines the removal function for the abandoned connection. The default is false.
When the connection is removed, the number of connections exceeds the value set for maxActive and is requested for connection.
The connection can be assigned when maxActive is not reached, abandoned connection removal does not occur.
|Sets the time for removal of abandoned timeout. The default is 300.|
Determines whether to abandon stack information in the log when removing abandoned connections. The default is false.
In the program, the connection obtained with JNDI Datasource as follows.
In this case, java:/comp/env is a prefix used when looking up JNDI.
The following is a jsp example program that integrates with ALTIBASE using the JNDI Datasource set above.
Integration with general JDBC method
- Load the JDBC driver.
- Get the Connection object.
- Get the Statement object.
- Execute the SQL statement and place it in the ResultSet.
- Close all related objects after the operation is completed.
The following is a jsp example program that integrates with ALTIBASe using the general JDBC method.