views:

486

answers:

1

Hello

I am trying to make db2 work in glassfish with no luck at all. I've read the documentation, but no matter what I do I end up stuck with an error when I do a ping. I put the jar files for the db2 driver and connectivity in the classpath prefix, added them to the lib directory of the domain and no go. What am I doing wrong? Thank you for your time.

A: 

You didn't mention anything about the datasource creation. Did you create a datasource ?

Here is how you can create one, in the domain.xml file in conf dir of your domain.

<jdbc-resource enabled="true" jndi-name="jdbc/<YOUR_DS_NAME_HERE>" object-type="user" pool-name="<YOUR_POOL_NAME_HERE>">
<description><DESCRIPTION></description>
</jdbc-resource>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.ibm.db2.jcc.DB2ConnectionPoolDataSource" fail-all-connections="true" idle-timeout-in-seconds="140" is-connection-validation-required="true" is-isolation-level-guaranteed="false" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="YOUR_POOL_NAME_HERE>" non-transactional-connections="false" pool-resize-quantity="32" res-type="javax.sql.ConnectionPoolDataSource" statement-timeout-in-seconds="-1" steady-pool-size="0" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<description><YOUR_POOL_NAME_HERE_DESCRIPTION></description>
<property name="user" value="<USERNAME>"/>
<property name="password" value="<PASSWORD>"/>
<property name="portNumber" value="<PORTNUMBER>"
<property name="databaseName" value="DATABASE_NAME"/>
<property name="serverName" value="<SERVER_NAME>"/>
<property name="driverType" value="4"/>
</jdbc-connection-pool>

You can also copy the jar files in the $GLASSFISH_HOME/lib dir.

rangalo
Iulia
Can you ping your datapool from the admin console ? What exception do you get ? Can you paste the stacktrace from server.log ?
rangalo
Ok, yes. Thank you!I finally realised what went wrong. First time I created the datasource, manually changed the driver type in the domain.xml file, but the .jar files were in all the wrong places. Second time I restarted from scratch (new connection pool, new data source) I had the .jar files in the right place (directly in the GLASSFISH_HOME/lib as you've stated), but forgot to do the manual changes in the xml. Brilliant me. *facepalm* Hopefully, someone else will learn from this. So, thank you again so very much for your help.
Iulia
You can accept the answer if it worked for you.
rangalo
Thank you again. I just feel the need to emphasize again, that the driverType part MUST be added by hand in the domain.xml file in order for this to work.
Iulia