Skip to end of metadata
Go to start of metadata


This chapter describes how to integrate ALTIBASE and JEUS.

JDBC Driver

JDBC is a standard interface that allows Java applications to connect the database and execute multiple SQLs.

These JDBC drivers are provided by each database vendor, and ALTIBASE provides the Altibase.jar file. This JDBC driver is located in the $ALTIBASE_HOME/lib directory. 

Starting from Altibase version 5, Altibase.jar and Altibase5.jar files are located in the $ALTIBASE_HOME/lib directory. Altibase.jar is a ALTIBASE JDBC driver file, and it can be used in Altibase version 5 and below. Therefore, if more than one ALTIBASE are integrating, the Altibase5.jar file is used.

JDBC Driver Setting

To integrate ALTIBASE and JEUS, the JDBC driver (Altibase.jar) provided by ALTIBASE must be located in the $JEUS_HOME/lib/datasource directory.

Connection Pooling

Connection pooling is a framework for caching DB connections. When the connection pool is started, it creates a certain number of physical connections, which reduces the overhead for creating connections during the application execution. The advantages of the connection pool are:

1. Better Performance

Creating DB connection is slow. All real connections in the connection pool are pre-made and ready to handle requests from the application. When the connection is no longer in use, it can be returned to the pool, reducing the overhead of dropping the connection.

2. Connection Management

The number of simultaneous connections can be controlled. By configuring the maximum number of simultaneous connections, the simultaneous connections of the DB can be limited.

Data Source

javax.sql.DataSource is the interface between the application and the connection pool. The javax.sql.DataSource object can be viewed as a factory for DB connections and provides many advantages over java.sql.DriverManager. In this document, the followings are the four types of data sources.

1. Basic Data Source

This returns connections for users. Because there is no connection pooling, there may be additional overhead compared to the connection pool type.

2. Connection Pool Data Source

This receives the connection stored in the connection pool and returns it to the application program. Because it uses the connection pooling function provided by JEUS, it has less overhead than the method of connecting to the DB every time and receiving the connection. When autocommit is set to false, the application can directly control local transactions.

3. XA Data Source

This manages connections used for distributed/global transactions. This data source format should be used only when 2PC (2 Phase Commit) is used. After starting a transaction in EJB or Servlet, 2PC-protocol starts automatically when starting the operating using two or more connections obtained from the XA data source. This connection cannot be used again after the transaction ends.

When using the XADataSource, the transaction recovery function is supported for each data source. For DB integration using the XADataSource, please refer to the ALTIBASE 5.3.3 API manual.

4. Local XA Data Source

Turn off autocommit to use a connection obtained from a connection pool data source so that local transactions are always on, and the transaction manager handles commits and rollbacks. Because of this, local transactions can be emulated to participate in XA. For reference, the local XA data source can be used when it is necessary to participate in XA even if the JDBC driver does not support the XA data source. The local XA data source may not recover properly due to functional limitations, and only one XA data source can participate in one global transaction.

Configuring data source

To integrate Altibase and JEUS, data sources in JEUSMain.xml can be configured. The properties of Javax.sql.DataSource are different for each driver, so the user needs to understand the characteristics of the driver to use and set it accordingly.

The following XML tags <resource><data-source>…<database> can be used as a sub tag of the XML tag.

Tag

Description

Vender

The name of DB vendor (oracle, mssql, db2, sybase, tibero, others).
ALTIBASE should be set to others.

Export-name

The name to be bound to JNDI. The data source object is bound by this name. The user can specify it arbitrarily.

Data-source-class-name

The data source class name by JDBC driver

ABConnectionPoolDataSource ( ALTIBASE 6.1.1 or lower),

AltibaseConnectionPoolDataSource ( ALTIBASE 6.3.1 or later) ,

This decides how to set BlackboxConnectionPoolDataSource.

Data-source-type

One of “DataSource”, “ConnectionPoolDataSource”, “XADataSource”, or “LocalXAData- Source” values.
This chooses according to the type of data source to be used.

Data-source-name

The name of the data source. It depends on the driver vendor and is usually the same as the DataSourceClass-Name value.

 

Database-name

The name of the DB (ex: mydb)

Service-name

Used only when using the Oracle inet driver, and the SID value of the Oracle Database. Not used in conjunction with ALTIBASE.

description

The description text of data source

Network-protocol

The protocol used to connect to DB

 

Password

The user password

 

User

The user name

Port-number

The port number of DB listener

Server -name

The DNS name or IP address of the server where the DB is running

Driver-type

For Oracle, the type of driver (ex. thin. oci)

Property

JDBC custom properties

When set to BlackboxConnectionPoolDataSource, specifies DriverClassName, URL, USER, and PASSWORD in this field.

 

Connection-pool

Sets the content specific to connection pooling.

Auto-commit

Specifies the autocommit value to be assigned to the connection. Set to true or false. In the case of local XA data sources or XA data sources, it is applied only when the connection is not linked to a transaction.

Action-on-connection-leak

Configures logging or return action for JDBC connection used in components (mainly stateless components-Servlet/JSP, Stateless Session Bean, MDB).
If not set, the default action follows the invocation-manager-action set in the engine container.

Icon

As the connection pool data source name, Altibase.jdbc.driver.ABConnectionPoolDataSource is used in versions lower than 6.1.1. Altibase.jdbc.driver.AltibaseConnectionPoolDataSource is used from ALTIBASE 6.3.1 or higher, so be cautious when setting the class.

If the class name is wrong, a java.lang.ClassNotFoundException: Altibase.jdbc.driver.ABConnectionPoolDataSource or java.lang.ClassNotFoundException: Altibase.jdbc.driverAltibaseConnectionPoolDataSource exception occurs in the jeus log.

Data Source Setting

There are two methods to set the data source to use in conjunction with ALTIBASE and JEUS: 
  1. Directly modifying the XML file in console mode
  2. Setting in GUI mode using the WebAdmin.

There are two methods of configuring and managing the connection pool when setting the data source: the AltibaseConnectionPoolDataSource method and the BlackboxConnecitonPoolDataSource is no JEUS, but ALTIBASE JDBC driver manages the connection pool, and BlackboxConnecitonDataSource is JEU manages the connection pool.

Let's set the connection pool using AltibaseConnectionPoolDataSource method and BlackboxConnectionPoolDataSource method to set the data source.

1. Set by the BlackboxConnectionPoolDataSource method

Setting by directly modifying the JEUSMain.xml file

Open the JEUSMain.xml file using a file editor and add the contents of <resource> ~ </resource>.

2. Setting by using the WebAdmin method

Let's set the connection pool with BlackboxConnectionPoolDataSource using the WebAdmin.

WebAdmin can be accessed at http://localhost:9744/WebAdmin, and by default, USER is the Administrator and password is the value set during installation. Here, the value of 9744 is the value of JEUS_BASSPORT + 8.

JEUS Manager menu of WebAdmin provides the function to boot, down, shut down by checking the desired node.
After booting the node with WebAdmin, click the JEUS manager resource  JDBC menu to create a new data source for integrating with ALTIBASE.
Select “Others” as the DBMS vendor, and select “BlackboxConnectionPoolDataSource” as the data source, and then proceed to the next step.
When creating a new JDBC data source, set each property value. Generally, if the user selects the DBMS vendor name and data source, "Vendor", "Data Source Class Name", "Data Source Type", and "Export Name" are set as follows. Change and use the property value only when it is needed, otherwise, just leave them.
Do not set the “Database Name”, “Port Name”, and “Server Name” property values, and set them in the “Property” item below and proceed to the next step. (When selecting and configuring with AltibaseConnectionPoolDataSource or XADataSource, set the values in “Database Name”, “Port Name”, and “Server Name” rather than “Property”).
"Property" value can be set as follows.

 

If the following values are not set in the “Property”, or if any of the values of “Database Name”, “Port Name”, and “Server Name” is set, an error occurs.

If the Min/Max value of the connection pool is set, the basic setting is completed.

After the creation is finished, the test and bind functions are available, and the user needs to bind to reflect the setting.

2. Set by using the AltibaseConnectionPoolDataSource method

Setting by directly modifying the JEUSMain.xml file

Open the JEUSMain.xml file using a file editor and add the contents of <resource> ~ </resource>.

  • Set by using the WebAdmin

JEUS can be started and shutdown, and data source can be set with the WebAdmin provided by JEUS. Property values set through WebAdmin are saved in JEUSMain.xml. If the user compares the JEUSMain.xml file before and after setting the property value, the user can see that the property value of ALTIBASE is modified between <resource> ~ </resource>.

Click "Create New JDBC Data Source" to create a new JDBC data source.

Select “Other” after selecting DBMS as “Other DataSource”.

Set "Data Source Class Name" ~"Password". When setting "Data Source Class Name", it should not be entered as AltibaseConnectionPoolDataSource, but must be entered in the complete form including the name and package name of the data source lass of the JDBC driver (Altibase.jdbc.driver.AltibaseConnectionPoolDataSource).

For connection pool, configuration, binding, and testing, please refer to the setting of BlackboxConnectionPoolDataSource.

Considerations when configuring the data source

  1. Considerations when using AltibaseConnectionPoolDataSource
  • When AltibaseConnectionPoolDataSource is set as Data-Source-Class-Name, properties such as “Encoding” and “maxPoolSize” can be specified and used, but when using BlackboxConnectionPoolDataSource, the property cannot be used.
  • URL-related method name changes according to the Altibase version. Therefore, a property name must be used to match the version.
Icon

For some versions, the method name related to URL setting is setUrl, and some versions are implemented as setURL. Therefore, URL properties must be set with respect to each version.

For version 6.3.1 or later, the URL should be set as follows (uppercase).

<property>
       <name>URL</name>
       <type>java.lang.String</type>
       <value>jdbc:Altibase://192.168.1.35:20300/mydb</value>
   </property>

For some versions, the URL should be set as follows (lowercase).

<property>
       <name>Url </name>
       <type>java.lang.String</type>
       <value>jdbc:Altibase://192.168.1.35:20300/mydb</value>
   </property>

If the property name is used incorrectly, an error such as java.lang.NoSuchMethodException: Altibase.jdbc.driver.ABConnectionPoolDataSource.setURL(java.lang.String) occurs, and after checking the error, edit JEUSMain.xml.

    2. Deadlock occurrence

  • When using AltibaseConnectionPoolDataSource and initialPoolSize, lock may occur. To solve this problem that occurs while using the values of pool to be used in JEUS in the ALTIBASE JDBC drive, use only the MaxPoolSize value instead of the initialPoolSize value.

Checking query

This function checks the status of the connection by sending a specific SELECT query when the application makes a JDBC connection request. This is useful to check for disconnection due to internal error of JDBC connection, socket disconnection by the firewall, and so forth. If the check fails, a new physical connection is created and it is returned to the application.

The check query function can be set in two methods. First, simply enter a query statement in the <check-query> tag in the setting, and the function can be extended by using the <check-query-class> tag.

Add directly between <database> ~ </database> in the JEUSMain.xml file. In the case of using WebAdmin, set the value after clicking on the connection pool and advanced options when creating or modifying a datasource.

1. Check-query setting

The query statement for the check query should enter a command for query only, not a command to update the DB.
<check-query>select 1 from dual</check-query>

2. Check-query-timeout setting (msec)

If there is no response from the DB server while executing the check-query, there may be a situation in which waiting indefinitely. To prevent this, check-query-timeout can be set. The setting value is msec, and if it is less than 1000msec, it is set to 0.
<check-query-timeout>20000</check-query-timeout>

3. Non-validation-interval setting (msec)

If overhead occurs due to the frequent use of check-query, it can be solved by setting Non-validation-interval.
If the difference between the time when performing check-query and the time when the last connection was used is between the settings of Non-validation-interval, do not execute the check-query.
<non-validation-interval>10000</non-validation-interval>

4. Destroy policy for check-query setting

If the check-query fails, the user can determine the destroy policy for the remaining connections in the connection pool as follows.

  • FailedConnectionOnly: Only discard the connection for which check-query. Default settings.

  • AllConnections: Discard all remaining connections.

Connection pool monitoring

There are two methods to monitor the connection pool: using jeusadmin and WebAdmin. This section describes how to monitor the connection pool by using jeusadmin.

When using jeusadmin, the command “dsinfo” is used to monitor the JDBC connection pool configured in the engine container. To monitor all connection pools configured in a container, specify the container name, and to monitor a single connection pool, specify the data source name created in the container.

 

 

Description

Name

The export name of DB pool

Min

The minimum size of connections maintained in the pool

Max

The maximum size of connections maintained in the pool

Act

The number of connection the application is using

 

Idle

The number of connections currently in the pool

Disp

The total number of connection once used and discarded

Tot

The total number of DB connections (active+idle+disposable connection)

Wait

Determines whether to make the thread wait if the connection is empty. If it is "true", it waits, and if it is "false", it makes a connection independent of the pool.

 

work

It is “true” if the DB pool is active, and “false” if it is inactive or not yet created.

Additionally, the user can use the 'dsconinfo' command to check the current status of connection for each data source or related statistics.

 

Description

Id

The unique value attached to each connection in the data source of the container

 

State

Indicates the connection state and there are 'active' and 'idle' states. If it is active, it means the connection is currently used

State time

The time that persists after the connection is changed to the current state

type

Distinguish the state between pooled and disposable connections

 

Usecount

Indicates how many times an op and close pair has ocurred

If the user knows the Export Name of the data source, you can test whether the pool is available with jeusadmin.

 

 

  • No labels