Each Datasource is implemented as a connection manager and manages a pool of JDBC connections. The pool can be configured via some additional properties described in the following table. Refer to the Oracle1.properties file to see an example of settings. All these settings have default values and are not required to be specified. All these attributes can be reconfigured when jonas is running from the jonas console.
Property Name | Description | Default Value |
---|---|---|
jdbc.connchecklevel | JDBC connection checking level: 0 (no check), 1 (check if the connection is still open), 2 (call the test statement before reusing a connection from the pool) | 1 |
jdbc.connmaxage | number of minutes a connection can be kept in the pool. If the minconpool limit has not been reached after this time, the connection will be closed. | 1440 minutes (= 1 day) |
jdbc.connteststmt | test statement in case jdbc.connchecklevel = 2 | select 1 |
jdbc.maxopentime | Maximum time (in minutes) that a connection can be left busy. If the caller has not issued a close() during this time, the connection will be closed automatically. | 1440 mn (= 1 day) |
jdbc.minconpool | Minimum number of connections in the pool. Setting a positive value here insures that the pool size will not go below this limit during the datasource's lifetime. | 0 |
jdbc.maxconpool | Maximum number of connections in the pool. Limiting the maximum pool size avoids errors from the database. | no limit |
jdbc.samplingperiod | Sampling period for JDBC monitoring (the number of seconds between two measures) | 60 sec |
jdbc.maxwaittime | Maximum time (in seconds) to wait for a connection in case of shortage. This is valid only if maxconpool has been set. | 10 sec |
jdbc.maxwaiters | Maximum number of concurrent waiters for a JDBC Connection. This is valid only if maxconpool has been set. | 1000 |
When a user requests a JDBC connection, the dbm connection manager first tries to see if a connection is already opened for its transaction. If not, JOnAS first tries to get a free connection from the free list. If there are no more connections available, the dbm connection manager creates a new JDBC connection (if jdbc.maxconpool is not reached). If it cannot create new connections, the user must wait (if jdbc.maxwaiters is not reached) until a connection is released. After a limited time (jdbc.maxwaittime), the getConnection returns an exception. When the user calls close() on the connection, the connection is put back in the free list. Many statistics are computed (every jdbc.samplingperiod seconds) and can be viewed by using the jonas console. This is useful for tuning these parameters and to see the server load at any time.
When a connection has existed for too long (jdbc.connmaxage), the pool tries to release it from the freelist. However, the dbm connection manager always tries to always keep at least jdbc.minconpool opened connections.
When the user has forgotten to close a JDBC connection, the system can automatically close it after jdbc.maxopentime minutes. Note that if the program tries to use this connection later expecting that it is still open, it returns an exception (socket closed).
When a connection is reused from the freelist, it is possible to verify if it is still valid. This is configured in jdbc.connchecklevel. The ultimate test is to try a dummy statement on the connection before returning it to the caller. This statement is configured by jdbc.connteststmt.