Skip to content

Connection Pool

Connection Pool#

A Connection Pool can be set and managed in the following manner.

  • Use AltibaseConnectionPoolDataSource When using a Connection Pool in WAS, specify this class in the JDBC Connection Pool configuration of WAS. The name of this class was ABConnectionPoolDataSource for Altibase JDBC drivers of versions prior to 6.3.1.

Property information configured in AltibaseConnectionPoolDataSource is as follows.

Property Name Description
databaseName Database name
dataSourceName DataSource Name
loginTimeout Maximum wait time for database login
logWriter Log writer for DataSource
password Database password
portNumber Database port number
serverName Database server name
URL Connection string information for Altibase connections (uppercase note)
user Database user ID

Configuring WAS (Web Application Server)#

Altibase can be used with the following web application servers.

  • Tomcat 8.x

    • Code example

      Context initContext = new InitialContext();
      Context envContext  = (Context)initContext.lookup("java:/comp/env");
      DataSource ds = (DataSource)envContext.lookup("jdbc/altihdb");
      Connection conn = ds.getConnection();
      // ...
      
  • WebLogic 12.x

  • Jeus 6.x

For more detailed information on how to configure and use the connection pool and JDBC driver on each web application, please refer to their manuals.

Tomcat 8.x#

For more detailed information on how to install and configure Apache Tomcat, please refer to http://tomcat.apache.org/tomcat-8.0-doc/index.html.

Context configuration#

Add the JNDI DataSource to the Context as below:

<Context>

 <Resource name="jdbc/altihdb" auth="Container" type="javax.sql.DataSource"
 driverClassName="Altibase.jdbc.driver.AltibaseDriver"
 url="jdbc:Altibase://localhost:20300/mydb" 
 username="SYS" password="MANAGER" 
 maxTotal="100" maxIdle="30" maxWaitMillis="10000" />

</Context>

web.xml configuration#

<!----- web.xml ----->
<resource-ref>
 <description>Altibase Datasource example</description>
 <res-ref-name>jdbc/altihdb</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
</resource-ref>

Code example#

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/altihdb");
Connection conn = ds.getConnection();
// ...

WebLogic 12.x#

For more detailed information on how to install and configure the WebLogic server, please refer to Oracle WebLogic Server.

The connection pool and the JDBC datasource can be configured by referring to the following links:

The configuration options for Altibase are as follows:

  • Database Type: Other
  • Driver Class Name: Altibase.jdbc.driver.AltibaseDriver
  • URL: jdbc:Altibase://localhost:20300/mydb

Jeus 6.x#

Set the Connection Pool by editing the element of the $JEUS_HOME/config/JeusMain.xml file.

<!------ JeusMain.xml ----->
<resource>
    <data-source>
        <database>
            <vendor>others</vendor>
            <export-name>jdbc/altihdb</export-name>
            <data-source-class-name>
                Altibase.jdbc.driver.AltibaseConnectionPoolDataSource
            </data-source-class-name>
            <data-source-type>ConnectionPoolDataSource</data-source-type>
            <auto-commit>true</auto-commit>
            <property>
                <name>PortNumber</name>
                <type>java.lang.Integer</type>
                <value>20300</value>
            </property>
            <property>
                <name>Password</name>
                <type>java.lang.String</type>
                <value>MANAGER</value>
            </property>
            <property>
                <name>ServerName</name>
                <type>java.lang.String</type>
                <value>localhost</value>
            </property>
            <property>
                <name>ConnectionAttributes</name>
                <type>java.lang.String</type>
                <value>;create=true</value>
            </property>
            <property>
                <name>DatabaseName</name>
                <type>java.lang.String</type>
                <value>mydb</value>
            </property>
            <property>
                <name>User</name>
                <type>java.lang.String</type>
                <value>SYS</value>
            </property>
        </database>
    </data-source>
</resource>

Validating Connections#

The Altibase JDBC driver supports a lightweight ping query for connection validation, which is more efficient than a regular query. It can be used in WAS (Web Application Server) with options like poolPingQuery or validationQuery.

The query patterns are as follows, and they can also be used with PreparedStatement:

/* PING */ SELECT 1
/* ping */ select 1
/*   PING  */ SELECT   1
/*   PING  */ select 1
/*   PING  */ select 1
/*   PING  */ select 1
/*   PING  */ seLECt 1
/*   ping  */ SELECT   1

The following pattens are not allowed.

/* PING */SELECT 1
/*+ ping */ select 1
/*ping  */ select 1
/* ping */ select 1 from dual
/** PING */ SELECT 1
//* PING */ SELECT 1