When connecting to db2 DB using DB connector, one can add the driver to the lib/user folder of the MULE ESB server. This is done to avoid having to package the driver to every application that will be deployed in the server. If the DB connector configuration is not done properly this can result in a not clean dispose of the DB2 driver when undeploying the application.
When an application that uses the db2 driver shared in /lib/user folder is deployed, undeployed and then deployed again, In this second deploy when the flow is exercised it will result in error:
java.sql.SQLException: Cannot get connection for URL ${boss.datasource.url} : No suitable driver found for ${boss.datasource.url}
at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:216)
at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:144)
at org.mule.module.db.internal.domain.connection.SimpleConnectionFactory.doCreateConnection(SimpleConnectionFactory.java:26)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
The issue happens when the db2 driver is not properly configured to be disposed when the application is undeployed.
<db:generic-config name="BOSS_Database"
url="${boss.datasource.url}"
driverClassName="com.ibm.db2.jcc.DB2Driver"
doc:name="Generic Database Configuration" />
Use the following configuration to ensure that the DB2 driver will be disposed properly. The key point is to set the "destroy-method" so it is invoked when the application is undeployed.
<spring:beans>
<spring:bean id="db2DataSource" name="db2DataSource" class="com.ibm.db2.jcc.DB2DataSource" destroy-method="finalize">
<spring:property name="serverName" value="127.0.0.1"/>
<spring:property name="portNumber" value="51620"/>
<spring:property name="databaseName" value="TEST"/>
<spring:property name="driverType" value="4"/>
<spring:property name="user" value="test"/>
<spring:property name="password" value="test"/>
<spring:property name="sslConnection" value="true"/>
<spring:property name="sslTrustStoreLocation" value="C:\db2_ssl\db2.jks"/>
<spring:property name="sslTrustStorePassword" value="test123"/>
</spring:bean>
</spring:beans>
<db:generic-config name="DB2_Database"
driverClassName="com.ibm.db2.jcc.DB2Driver"
doc:name="Generic Database Configuration" dataSource-ref="db2DataSource"/>
001118965

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.