Database Connection



The details entered on the Configure Database Connection dialog specify how the Enterprise Gateway connects to the database. The Enterprise Gateway maintains a JDBC pool of database connections to avoid the overhead of setting up and tearing down connections to service simultaneous requests. This pool is implemented using Apache Commons DBCP (Database Connection Pools). The settings in the Advanced - Connection pool section of this screen configure the database connection pool. For details on how the fields on this screen correspond to specific DBCP configuration settings, see the Database Connection Pool Settings table.

Configuring the Database Connection

Configure the following fields on this screen:

Enter a name for the database connection in the Name field.

Enter the fully qualified URL of the location of the database.

User Name:
The username to use to access the database.

The password for the user specified in the User Name field.

Initial pool size:
The initial size of the DBCP pool when it is first created.

Maximum number of active connections:
The maximum number of active connections that can be allocated from the JDBC pool at the same time. The default maximum is 8 active connections.

Maximum number of idle connections:
The maximum number of active connections that can remain idle in the pool without extra connections being released. The default maximum is 8 connections.

Minimum number of idle connections:
The minimum number of active connections that can remain idle in the pool without extra connections being created. The default minimum is 8 connections.

Maximum wait time:
The maximum number of milliseconds that the pool waits (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely. The default time is 10000ms, and a value of -1 indicates an indefinite time to wait.

Time between eviction:
The number of milliseconds to sleep between runs of the thread that evicts unused connections from the JDBC pool.

Number of tests:
The number of connection objects to examine from the pool during each run of the evictor thread. The default number of objects is 3.

Minimum idle time:
The minimum amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any).

Database Connection Pool Settings

The table below shows the correspondence between the fields in the Advanced - Connection pool section of the screen and the Apache Commons DBCP configuration properties:

Field Name DBCP Configuration Property
URL url
User Name username
Password password
Initial pool size initialSize
Maximum number of active connections maxActive
Maximum number of idle connections maxIdle
Minimum number of idle connections minIdle
Maximum wait time maxWait
Time between eviction timeBetweenEvictionRunsMillis
Number of tests numTestsPerEvictionRun
Minimum idle time minEvictableIdleTimeMillis

Connection Validation

By default, when the Enterprise Gateway makes a connection, it performs a simple connection validation query. This enables the Enterprise Gateway to test the database connection before use, and to recover if the database goes down (for example, if there is a network failure, or if the database server reboots). The Enterprise Gateway validates connections by running a simple SQL query (for example, a SELECT 1 query with MySQL). If it detects a broken connection, it creates a new connection to replace it.

Test the Connection

When you have specified all the database connection details, you can click the Test Connection button to verify that the connection to the database is configured successfully. This enables you to detect any configuration errors at design time instead at runtime.