The <dbcp-connection-pool> database configuration element

The <database> element in file database-config.xml contains, at most, a single occurrence of subelement <dbcp-connection-pool>. The use of the <dbcp-connection-pool> element is optional. If using PolicyCenter to manage the connection pool rather than a JNDI data source managed by the application server, you must use this element to configure the connection pool behavior.

Note: Guidewire implements its own version of the Apache Commons Pool, overriding specific values to provide improved functionality.

If you experience slow performance, it is possible that the PolicyCenter server is not allocating enough database connections. If all database connections are in use, any client attempting to connect to the server must wait until a connection is free. By default, PolicyCenter periodically tests connections in the connection pool using a simple query and evicts idle connections and those that fail with an exception.

The <dbcp-connection-pool> element has the following syntax. The following code sample shows required attributes in bold font.

<database>

   <!-- Sets options for the connection pool that Guidewire provides -->
  <dbcp-connection-pool jdbc-url="string" max-idle="integer" max-total="integer" max-wait="integer"
        min-evictable-idle-time="integer" num-tests-per-eviction-run="integer" password-file="string"
        test-on-borrow="true|false" test-on-return="true|false" test-while-idle="true|false" 
        time-between-eviction-runs="integer" when-exhausted-action="block|fail|grow">
    <reset-tools-params collation="string" oracle-tnsnames="string" system-password="string"
          system-username="string"/>
  </dbcp-connection-pool>

 </database>

The following list describes the attributes that you can configure on the <dbcp-connection-pool> element.

Note: These attributes apply only if you use the default connection pool. If you use the server connection pool, these settings do not apply. Configure the server connection pool instead through the administration console provided with the server. See Configure PolicyCenter to use a direct JNDI data source for more information.

jdbc-url

Required. Stores connection information for the database. The format of the jdbc-url value changes depending on the database type. See The JDBC URL format for more information.

The following attributes are all optional.

max-idle

Maximum number of connections that can sit idle in the pool at any time. If negative, there is no limit to the number of connections that can be idle at any given time. The default is -1.

max-total

Maximum number of connections that the connection pool can allocate, including those in use by a client or that are in an idle state awaiting use. A reasonable initial value for this is about 25% of the number of users that you expect to use PolicyCenter at the same time.

If you increase the number of workers for a work queue for a batch process, then you also need to increase the possible number of database connections by setting max-total to a larger number.

If you set max-total to a negative number, there is no limit to the number of allowed database connections. The attribute default is -1.

If you configure max-total for an insufficient number of connections, and, you set max-wait to a negative number (no timeout), it has the possibility to cause the application server to deadlock.

If the number of database connections reaches the value of max-total, PolicyCenter considers the connection pool to have no more available connections.

max-wait

Maximum amount of time, in milliseconds, that the data source waits for a connection before one becomes available in the pool to service. The default is 30000.

Guidewire recommends that you do not set the value of this attribute to a negative number (infinite wait time). If it is not possible to deliver a connection in a reasonable amount of time, you want the connection request to time out and to issue an error.

The value of the max-wait attribute interacts with the when-exhausted-action attribute. See that attribute for more information.

min-evictable-idle-time

Maximum time, in milliseconds, that a connection can sit idle in the pool before it is eligible for eviction due to idle time. If a connection is idle more the specified number of milliseconds, PolicyCenter evicts the connection from the pool. The default is 300000 milliseconds.

If this value is a non-positive integer, PolicyCenter does not drop connections from the pool due to idle time alone. This setting has no effect unless the value of time-between-eviction-runs is greater than 0.

During an eviction run, PolicyCenter scans the connection pool and tests the number of idle connections equal to the value of num-tests-per-eviction-run.

num-tests-per-eviction-run

Number of idle connections that PolicyCenter tests in each eviction run. This setting has no effect unless the value of time-between-eviction-runs is greater than 0. The default is 3.

password-file

Use to hide the value of the database connection password in the jdbc-url connection string. Instead of providing the password in the connection string, you can place the password in an external file and reference this file from file database-config.xml. See Obfuscating the database password for more information.

test-on-borrow

Boolean. Whether PolicyCenter tests a connection by running a simple validation query as PolicyCenter first borrows the connection from the connection pool. If set to true, the connection pool attempts to validate each connection before PolicyCenter uses the connection from the connection pool. If a connection fails validation, the connection pool drops the connection and chooses a different connection to borrow. The default is false.

PolicyCenter returns any connection used only for a query to the pool immediately after the query completes. Thus, running a test query every time that a connection returns to the pool can potentially affect performance.

test-on-return

Boolean. Whether PolicyCenter tests a connection by running a simple validation query as PolicyCenter returns the connection to the connection pool. If set to true, the connection pool attempts to validate each connection that PolicyCenter returns from the database. The default is false.

PolicyCenter returns any connection used only for a query to the pool immediately after the query completes. Thus, running a test query every time that a connection returns to the pool can potentially affect performance.

test-while-idle

Boolean. Whether PolicyCenter performs validation on idle connections in the connection pool. If set to true, the connection pool performs validation on idle connections. It drops connections that fail the validation test. The default is true.

This attribute value has no effect unless the value of time-between-eviction-runs is greater than zero.

time-between-eviction-runs

Time, in milliseconds, that PolicyCenter waits between eviction runs of idle connections in the connection pool. The default is 60000.

If set to a a non-positive integer, PolicyCenter does not launch any eviction threads.

when-exhausted-action

Specifies the behavior of the connection pool if the pool has no more connections. Set this attribute to one of the following values:

  • fail – If the there are no more connections available, PolicyCenter throws a NoSuchElementException exception.
  • grow – If there are no more connections available, PolicyCenter creates a new connection and returns it, essentially making max-active meaningless.
  • block – If there are no more connections available, PolicyCenter blocks connections until a new or idle connection becomes available. If the value of max-wait is positive, then PolicyCenter blocks, at most, for that number of milliseconds, after which PolicyCenter throws a NoSuchElementException exception. If the value of max-wait is non-positive, PolicyCenter blocks indefinitely.

The default is block.

The <dbcp-connection-pool> element has the following subelement.

reset-tools-params

See The <reset-tool-params> database configuration element for more information.

See also