Introduction
In the connections configuration you can specify how to connect to the data sources. Connections configuration can be found in PENROSE_SERVER_HOME/conf/connections.xml.
<connections>
<connection name="...">
<adapter-name>...</adapter-name>
<parameter>
<param-name>...</param-name>
<param-value>...</param-value>
</parameter>
</connection>
</connections>
Name
Assign a name to your connections.
Adapter Name
Adapter determines the type of connection (JDBC, JNDI, etc.). See Adapters.
Parameters
Each type of adapter has its own set of parameters. See below.
JDBC Connection
JDBC connection allows you to connect to various databases.
| Parameter | Description | Example |
|---|---|---|
| driver | JDBC Driver class name | com.mysql.jdbc.Driver |
| url | JDBC URL | jdbc:mysql://localhost/example?autoReconnect=true |
| user | Username | penrose |
| password | Password | penrose |
Penrose uses DBCP for JDBC connection pooling. The following parameters are supported:
| Parameter | Description |
|---|---|
| maxActive | The maximum number of active connections that can be allocated from this pool at the same time, or zero for no limit. |
| maxIdle | The maximum number of active connections that can remain idle in the pool, without extra ones being released, or zero for no limit. |
| minIdle | The minimum number of active connections that can remain idle in the pool, without extra ones being created, or zero to create none. |
| maxWait | The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely. |
| validationQuery | The SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. |
| testOnBorrow | The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. |
| testOnReturn | The indication of whether objects will be validated before being returned to the pool. |
| testWhileIdle | The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool. |
| timeBetweenEvictionRunsMillis | The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run. |
| numTestsPerEvictionRun | The number of objects to examine during each run of the idle object evictor thread (if any). |
| minEvictableIdleTimeMillis | The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any). |
See also:
- http://jakarta.apache.org/commons/pool/apidocs/org/apache/commons/pool/impl/GenericObjectPool.html

- http://jakarta.apache.org/commons/dbcp/configuration.html

Here is an example:
<connection name="MySQL"> <adapter-name>JDBC</adapter-name> <parameter> <param-name>user</param-name> <param-value>penrose</param-value> </parameter> <parameter> <param-name>password</param-name> <param-value>penrose</param-value> </parameter> <parameter> <param-name>url</param-name> <param-value>jdbc:mysql://localhost/example?autoReconnect=true</param-value> </parameter> <parameter> <param-name>driver</param-name> <param-value>com.mysql.jdbc.Driver</param-value> </parameter> </connection>
JNDI Connection
JNDI connection allows you to connect to various directory servers.
| Parameter | Description | Example |
|---|---|---|
| java.naming.factory.initial | Initial context factory | com.sun.jndi.ldap.LdapCtxFactory |
| java.naming.provider.url | URL | ldap://localhost/dc=penrose,dc=safehaus,dc=org |
| java.naming.security.principal | Principal | cn=Directory Manager |
| java.naming.security.credentials | Password | secret |
| com.sun.jndi.ldap.connect.pool | Enable connection pooling (boolean) | true |
Penrose relies on Sun's JNDI to provide connection pooling. To configure the connection pooling you need to set the following system properties. You can set the system properties either in server.xml, in the command line parameters, or programmatically by invoking System.setProperty(), but not in the connection parameters above.
| System Property | Description |
|---|---|
| com.sun.jndi.ldap.connect.pool.authentication | A list of space-separated authentication types of connections that may be pooled. Valid types are "none", "simple", and "DIGEST-MD5". |
| com.sun.jndi.ldap.connect.pool.debug | A string that indicates the level of debug output to produce. Valid values are "fine" (trace connection creation and removal) and "all" (all debugging information). |
| com.sun.jndi.ldap.connect.pool.initsize | The string representation of an integer that represents the number of connections per connection identity to create when initially creating a connection for the identity. |
| com.sun.jndi.ldap.connect.pool.maxsize | The string representation of an integer that represents the maximum number of connections per connection identity that can be maintained concurrently. |
| com.sun.jndi.ldap.connect.pool.prefsize | The string representation of an integer that represents the preferred number of connections per connection identity that should be maintained concurrently. |
| com.sun.jndi.ldap.connect.pool.protocol | A list of space-separated protocol types of connections that may be pooled. Valid types are "plain" and "ssl". |
| com.sun.jndi.ldap.connect.pool.timeout | The string representation of an integer that represents the number of milliseconds that an idle connection may remain in the pool without being closed and removed from the pool. |
See also:
Here is an example:
<connection name="SunONE"> <adapter-name>JNDI</adapter-name> <parameter> <param-name>java.naming.provider.url</param-name> <param-value>ldap://localhost/dc=penrose,dc=safehaus,dc=org</param-value> </parameter> <parameter> <param-name>java.naming.factory.initial</param-name> <param-value>com.sun.jndi.ldap.LdapCtxFactory</param-value> </parameter> <parameter> <param-name>java.naming.security.principal</param-name> <param-value>cn=Directory Manager</param-value> </parameter> <parameter> <param-name>java.naming.security.credentials</param-name> <param-value>secret</param-value> </parameter> </connection>