Skip to content

Commit 753c7bf

Browse files
committed
Fix for EAP7-2299, Support for Configuring DB2 Database Driver in EAP 8 Using Galleon
1 parent 16b8641 commit 753c7bf

File tree

9 files changed

+288
-3
lines changed

9 files changed

+288
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ For each database type it supports, the feature-pack provides 3 Galleon layers t
3636

3737
The linked documentation provides information about how to configure each supported database type:
3838

39+
* [DB2 driver and datasource](doc/db2/README.md)
40+
3941
* [Microsoft SQL Server driver and datasource](doc/mssqlserver/README.md)
4042

4143
* [Oracle driver and datasource](doc/oracle/README.md)

doc/db2/README.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
Galleon Layers
2+
=========
3+
4+
* `db2-datasource`: Provision the `DB2DS` non xa datasource. Depends on `db2-driver` layer.
5+
* `db2-driver`: Provision the `db2` driver. This layer installs the JBoss Modules module `com.ibm.db2`.
6+
7+
Build time configuration
8+
===============
9+
10+
Configuration to provide when provisioning the Galleon feature-pack.
11+
12+
Required configuration
13+
--------------------------------
14+
15+
* `DB2_DRIVER_VERSION`
16+
17+
* Description: The version of the `com.ibm.db2:jcc` Maven artifact.
18+
* No default value.
19+
* Required: True
20+
* System Property: `org.jboss.eap.datasources.db2.driver.version`
21+
22+
Runtime Configuration
23+
==============
24+
25+
The following set of environment variables and corresponding Java system properties can be used to configure the datasource.
26+
27+
Required configuration
28+
--------------------------------
29+
30+
* `DB2_DATABASE`
31+
32+
* Description: Defines the database name to be used in the datasource’s `connection-url` property.
33+
* No default value.
34+
* Required: True if `DB2_URL` is not set.
35+
* System Property: `org.jboss.eap.datasources.db2.database`
36+
37+
* `DB2_PASSWORD`
38+
39+
* Description: Defines the password for the datasource.
40+
* No default value.
41+
* Required: True
42+
* System Property: `org.jboss.eap.datasources.db2.password`
43+
44+
* `DB2_URL`
45+
46+
* Description: Defines the connection URL for the datasource.
47+
* Default Value: `jdbc:db2://${DB2_HOST}:${DB2_PORT}/${DB2_DATABASE}`
48+
* Required: True if `DB2_PORT/HOST/DATABASE` are not set.
49+
* System Property: `org.jboss.eap.datasources.db2.connection-url`
50+
51+
* `DB2_USER`
52+
53+
* Description: Defines the username for the datasource.
54+
* No default value.
55+
* Required: True
56+
* System Property: `org.jboss.eap.datasources.db2.user-name`
57+
58+
Optional configuration
59+
==============
60+
61+
* `DB2_BACKGROUND_VALIDATION`
62+
63+
* Description: When set to true database connections are validated periodically in a background thread prior to use. Defaults to false, meaning the `validate-on-match` method is enabled by default instead.
64+
* Default Value: `false`
65+
* System Property: `org.jboss.eap.datasources.db2.background-validation`
66+
67+
* `DB2_BACKGROUND_VALIDATION_MILLIS`
68+
69+
* Description: Specifies frequency of the validation, in milliseconds, when the `background-validation` database connection validation mechanism is enabled.
70+
* Default Value: `10000`
71+
* System Property: `org.jboss.eap.datasources.db2.background-validation-millis`
72+
73+
* `DB2_CONNECTION_CHECKER`
74+
75+
* Description: Specifies a connection checker class that is used to validate connections. Valid value: `org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker`
76+
* Default Value: `org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker`
77+
* System Property: `org.jboss.eap.datasources.db2.valid-connection-checker-class-name`
78+
79+
* `DB2_DATASOURCE`
80+
81+
* Description: Datasource name used in the `jndi-name`.
82+
* Default Value: `DB2DS`
83+
* System Property: `org.jboss.eap.datasources.db2.datasource`
84+
85+
* `DB2_ENABLED`
86+
87+
* Description: Set to false to disable the datasource.
88+
* Default Value: `true`
89+
* System Property: `org.jboss.eap.datasources.db2.enabled`
90+
91+
* `DB2_EXCEPTION_SORTER`
92+
93+
* Description: Specifies the exception sorter class that is used to properly detect and clean up after fatal database connection exceptions. Valid value: `org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter`
94+
* Default Value: `org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter`
95+
* System Property: `org.jboss.eap.datasources.db2.exception-sorter-class-name`
96+
97+
* `DB2_FLUSH_STRATEGY`
98+
99+
* Description: Specifies how the datasource should be flushed in case of an error.
100+
* Default Value: `FailingConnectionOnly`
101+
* System Property: `org.jboss.eap.datasources.db2.flush-strategy`
102+
103+
* `DB2_HOST` (or `DB2_SERVICE_HOST`)
104+
105+
* Description: Defines the database server’s host name or IP address to be used in the datasource’s `connection-url` property.
106+
* Default Value: `localhost`
107+
* Required: True if `DB2_URL` is not set.
108+
* System Property: `org.jboss.eap.datasources.db2.host`
109+
110+
* `DB2_IDLE_TIMEOUT_MINUTES`
111+
112+
* Description: Specifies the maximum time, in minutes, a connection may be idle before being closed.
113+
* Default Value:`30`
114+
* System Property: `org.jboss.eap.datasources.db2.idle-timeout-minutes`
115+
116+
* `DB2_JNDI`
117+
118+
* Description: Defines the JNDI name for the datasource.
119+
* Default Value:` java:jboss/datasources/${DB2_DATASOURCE}`
120+
* System Property: `org.jboss.eap.datasources.db2.jndi-name`
121+
122+
* `DB2_JTA`
123+
124+
* Description: Defines Java Transaction API (JTA) option for the non-XA datasource.
125+
* Default Value: `true`
126+
* System Property: `org.jboss.eap.datasources.db2.jta`
127+
128+
* `DB2_MAX_POOL_SIZE`
129+
130+
* Description: Defines the maximum pool size option for the datasource.
131+
* Default Value: `20`
132+
* System Property: `org.jboss.eap.datasources.db2.max-pool-size`
133+
134+
* `DB2_MIN_POOL_SIZE`
135+
136+
* Description: Defines the minimum pool size option for the datasource.
137+
* Default Value: `0`
138+
* System Property: `org.jboss.eap.datasources.db2.min-pool-size`
139+
140+
* `DB2_PORT` (or `DB2_SERVICE_PORT`)
141+
142+
* Description: Defines the database server’s port to be used in the datasource’s `connection-url` property.
143+
* Default Value: `50000`
144+
* Required: True if `DB2_URL` is not set.
145+
* System Property: `org.jboss.eap.datasources.db2.port`
146+
147+
* `DB2_STALE_CONNECTION_CHECKER`
148+
149+
* Description: Specifies a connection checker class that is used to check stale connections. Valid value: `org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker`
150+
* Default Value: `org.jboss.jca.adapters.jdbc.extensions.novendor.NullStaleConnectionChecker`
151+
* System Property: `org.jboss.eap.datasources.db2.stale-connection-checker-class-name`
152+
153+
* `DB2_TX_ISOLATION`
154+
155+
* Description: Defines the `java.sql.Connection` transaction isolation level for the datasource.
156+
* Default Value: `TRANSACTION_READ_COMMITTED`
157+
* System Property: `org.jboss.eap.datasources.db2.transaction-isolation`
158+
159+
* `DB2_VALIDATE_ON_MATCH`
160+
161+
* Description: Indicates whether or not connection level validation should be done when a connection factory attempts to match a managed connection for a given set. This is typically exclusive to the use of background validation.
162+
* Default Value: `true`
163+
* System Property: `org.jboss.eap.datasources.db2.validate-on-match`
164+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" ?>
2+
<layer-spec xmlns="urn:jboss:galleon:layer-spec:1.0" name="db2-datasource">
3+
<dependencies>
4+
<layer name="db2-driver"/>
5+
</dependencies>
6+
7+
<feature spec="subsystem.datasources.data-source">
8+
<!-- we can't use expression for pool-name (data-source name) hard coding should be fine, the important thing is JNDI -->
9+
<param name="data-source" value="DB2DS"/>
10+
<param name="enabled" value="${org.jboss.eap.datasources.db2.enabled, env.DB2_ENABLED:true}"/>
11+
<param name="exception-sorter-class-name" value="${org.jboss.eap.datasources.db2.exception-sorter-class-name, env.DB2_EXCEPTION_SORTER:org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter}"/>
12+
<param name="idle-timeout-minutes" value="${org.jboss.eap.datasources.db2.idle-timeout-minutes,env.DB2_IDLE_TIMEOUT_MINUTES:30}"/>
13+
<param name="jndi-name" value="${org.jboss.eap.datasources.db2.jndi-name,env.DB2_JNDI:java:jboss/datasources/${org.jboss.eap.datasources.db2.datasource, env.DB2_DATASOURCE:DB2DS}}"/>
14+
<param name="jta" value="${org.jboss.eap.datasources.db2.jta,env.DB2_JTA:true}"/>
15+
<param name="max-pool-size" value="${org.jboss.eap.datasources.db2.max-pool-size,env.DB2_MAX_POOL_SIZE:20}"/>
16+
<param name="min-pool-size" value="${org.jboss.eap.datasources.db2.min-pool-size,env.DB2_MIN_POOL_SIZE:0}"/>
17+
<param name="connection-url" value="${org.jboss.eap.datasources.db2.connection-url,env.DB2_URL:jdbc:db2://${org.jboss.eap.datasources.db2.host,env.DB2_SERVICE_HOST,env.DB2_HOST:localhost}:${org.jboss.eap.datasources.db2.port,env.DB2_SERVICE_PORT,env.DB2_PORT:50000}/${org.jboss.eap.datasources.db2.database,env.DB2_DATABASE}}"/>
18+
<param name="driver-name" value="db2"/>
19+
<param name="user-name" value="${org.jboss.eap.datasources.db2.user-name,env.DB2_USER}"/>
20+
<param name="password" value="${org.jboss.eap.datasources.db2.password,env.DB2_PASSWORD}"/>
21+
<param name="validate-on-match" value="${org.jboss.eap.datasources.db2.validate-on-match,env.DB2_VALIDATE_ON_MATCH:true}"/>
22+
<param name="background-validation" value="${org.jboss.eap.datasources.db2.background-validation,env.DB2_BACKGROUND_VALIDATION:false}"/>
23+
<param name="background-validation-millis" value="${org.jboss.eap.datasources.db2.background-validation-millis,env.DB2_BACKGROUND_VALIDATION_MILLIS:10000}"/>
24+
<param name="flush-strategy" value="${org.jboss.eap.datasources.db2.flush-strategy,env.DB2_FLUSH_STRATEGY:FailingConnectionOnly}"/>
25+
<param name="statistics-enabled" value="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}" />
26+
<param name="stale-connection-checker-class-name" value="${org.jboss.eap.datasources.db2.stale-connection-checker-class-name,env.DB2_STALE_CONNECTION_CHECKER:org.jboss.jca.adapters.jdbc.extensions.novendor.NullStaleConnectionChecker}" />
27+
<param name="valid-connection-checker-class-name" value="${org.jboss.eap.datasources.db2.valid-connection-checker-class-name,env.DB2_CONNECTION_CHECKER:org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker}"/>
28+
<param name="transaction-isolation" value="${org.jboss.eap.datasources.db2.transaction-isolation,env.DB2_TX_ISOLATION:TRANSACTION_READ_COMMITTED}"/>
29+
</feature>
30+
</layer-spec>
31+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" ?>
2+
<layer-spec xmlns="urn:jboss:galleon:layer-spec:1.0" name="db2-driver">
3+
<feature spec="subsystem.datasources">
4+
<feature spec="subsystem.datasources.jdbc-driver">
5+
<param name="driver-name" value="db2"/>
6+
<param name="jdbc-driver" value="db2"/>
7+
<param name="driver-xa-datasource-class-name" value="com.ibm.db2.jcc.DB2XADataSource"/>
8+
<param name="driver-module-name" value="com.ibm.db2"/>
9+
</feature>
10+
</feature>
11+
<packages>
12+
<package name="com.ibm.db2"/>
13+
</packages>
14+
</layer-spec>
15+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module name="com.ibm.db2" xmlns="urn:jboss:module:1.8">
3+
<resources>
4+
<artifact name="${com.ibm.db2:jcc}"/>
5+
</resources>
6+
<dependencies>
7+
<module name="wildflyee.api"/>
8+
</dependencies>
9+
</module>
10+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
com.microsoft.sqlserver:mssql-jdbc=com.microsoft.sqlserver:mssql-jdbc:${org.jboss.eap.datasources.mssqlserver.driver.version,env.MSSQLSERVER_DRIVER_VERSION}::jar
22
com.oracle.database.jdbc:ojdbc=${org.jboss.eap.datasources.oracle.driver.groupId,env.ORACLE_DRIVER_GROUP_ID:com.oracle.database.jdbc}:${org.jboss.eap.datasources.oracle.driver.artifactId,env.ORACLE_DRIVER_ARTIFACT_ID:ojdbc17}:${org.jboss.eap.datasources.oracle.driver.version,env.ORACLE_DRIVER_VERSION}::jar
33
org.postgresql:postgresql=org.postgresql:postgresql:${org.jboss.eap.datasources.postgresql.driver.version,env.POSTGRESQL_DRIVER_VERSION}::jar
4+
com.ibm.db2:jcc=com.ibm.db2:jcc:${org.jboss.eap.datasources.db2.driver.version,env.DB2_DRIVER_VERSION}::jar

testsuite/galleon/pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
<artifactId>mssql-jdbc</artifactId>
7878
<scope>test</scope>
7979
</dependency>
80+
<dependency>
81+
<groupId>com.ibm.db2</groupId>
82+
<artifactId>jcc</artifactId>
83+
<scope>test</scope>
84+
</dependency>
8085
<!-- end for dependabot -->
8186
</dependencies>
8287
<build>
@@ -103,6 +108,10 @@
103108
<name>org.jboss.eap.datasources.mssqlserver.driver.version</name>
104109
<value>${org.jboss.eap.datasources.mssqlserver.driver.version}</value>
105110
</property>
111+
<property>
112+
<name>org.jboss.eap.datasources.db2.driver.version</name>
113+
<value>${org.jboss.eap.datasources.db2.driver.version}</value>
114+
</property>
106115
</properties>
107116
</configuration>
108117
</execution>
@@ -130,6 +139,7 @@
130139
<layer>oracle-datasource</layer>
131140
<layer>postgresql-datasource</layer>
132141
<layer>mssqlserver-datasource</layer>
142+
<layer>db2-datasource</layer>
133143
</layers>
134144
<galleon-options>
135145
<jboss-fork-embedded>${plugin.fork.embedded}</jboss-fork-embedded>
@@ -220,6 +230,23 @@
220230
<MSSQLSERVER_TX_ISOLATION>TRANSACTION_READ_UNCOMMITTED</MSSQLSERVER_TX_ISOLATION>
221231
<MSSQLSERVER_FLUSH_STRATEGY>IdleConnections</MSSQLSERVER_FLUSH_STRATEGY>
222232

233+
<DB2_ENABLED>false</DB2_ENABLED>
234+
<DB2_EXCEPTION_SORTER>envfoo</DB2_EXCEPTION_SORTER>
235+
<DB2_IDLE_TIMEOUT_MINUTES>40</DB2_IDLE_TIMEOUT_MINUTES>
236+
<DB2_JNDI>envbar</DB2_JNDI>
237+
<DB2_JTA>false</DB2_JTA>
238+
<DB2_MAX_POOL_SIZE>8888</DB2_MAX_POOL_SIZE>
239+
<DB2_MIN_POOL_SIZE>77</DB2_MIN_POOL_SIZE>
240+
<DB2_URL>envfoourl</DB2_URL>
241+
<DB2_USER>envfoouser</DB2_USER>
242+
<DB2_PASSWORD>envfoopassword</DB2_PASSWORD>
243+
<DB2_VALIDATE_ON_MATCH>false</DB2_VALIDATE_ON_MATCH>
244+
<DB2_BACKGROUND_VALIDATION>true</DB2_BACKGROUND_VALIDATION>
245+
<DB2_BACKGROUND_VALIDATION_MILLIS>7</DB2_BACKGROUND_VALIDATION_MILLIS>
246+
<DB2_STALE_CONNECTION_CHECKER>envfoostalechecker</DB2_STALE_CONNECTION_CHECKER>
247+
<DB2_CONNECTION_CHECKER>envfoochecker</DB2_CONNECTION_CHECKER>
248+
<DB2_TX_ISOLATION>TRANSACTION_READ_UNCOMMITTED</DB2_TX_ISOLATION>
249+
<DB2_FLUSH_STRATEGY>IdleConnections</DB2_FLUSH_STRATEGY>
223250
</environmentVariables>
224251
</configuration>
225252
</execution>
@@ -244,6 +271,11 @@
244271
<MSSQLSERVER_DATASOURCE>envbardatasource</MSSQLSERVER_DATASOURCE>
245272

246273
<ORACLE_DATASOURCE>envbardatasource</ORACLE_DATASOURCE>
274+
275+
<DB2_HOST>envfoohost</DB2_HOST>
276+
<DB2_PORT>envfooport</DB2_PORT>
277+
<DB2_DATABASE>envbardatabase</DB2_DATABASE>
278+
<DB2_DATASOURCE>envbardatasource</DB2_DATASOURCE>
247279
</environmentVariables>
248280
</configuration>
249281
</execution>
@@ -268,6 +300,11 @@
268300
<MSSQLSERVER_DATASOURCE>envbardatasource</MSSQLSERVER_DATASOURCE>
269301

270302
<ORACLE_DATASOURCE>envbardatasource</ORACLE_DATASOURCE>
303+
304+
<DB2_SERVICE_HOST>envfoohost</DB2_SERVICE_HOST>
305+
<DB2_SERVICE_PORT>envfooport</DB2_SERVICE_PORT>
306+
<DB2_DATABASE>envbardatabase</DB2_DATABASE>
307+
<DB2_DATASOURCE>envbardatasource</DB2_DATASOURCE>
271308
</environmentVariables>
272309
</configuration>
273310
</execution>

0 commit comments

Comments
 (0)