Skip to main content

DB2 Connection Pool

10 replies [Last post]
Joined: 2006-09-13

Server 9.1 (build b41d-beta2)

I am trying to setup connection pool .
DatabaseSource Classname:
Resource Type: javax.sql.DataSource

I am getting the following error when I click on the Ping button cannot be cast to javax.sql.DataSource

What am I doing wrong or how can I fix it, or does anyone has instructions on how to setup a connection pool for DB2?

Thank You


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-10-18

This worked for me also thanks heaps!

The important setting is driverType="4" and this will then also not require any of the dll/so files within library path

Have tested against DB2 8.2 z/OS and it also works a treat :) (as long as db2jcc_license_cisuz is also installed in lib directory)

Joined: 2007-02-23

It's right there, your resource type is a DataSouce but you're providing a Driver class.

Check out:

Hint: Use the DatabaseSource Classname of "com.sun.sql.jdbcx.db2.DB2DataSource"

That should work.

Joined: 2006-09-13

Thank you for you help
Unfortunately if does not work

I do not have Sun db2 driver and I could not find them anywhere on the web
I have IBM jdbc driver but I can not get them to work
when I try
I get this error: Failure in loading T2 native library db2jcct2

When I try com.sun.sql.jdbcx.db2.DB2DataSource
I get this error
Class name is wrong or classpath is not set for : com.sun.sql.jdbcx.db2.DB2DataSource

Joined: 2005-04-13

have you specified all the environment variables with appropriate values, as directed in
Do you have the native library available ?

com.sun.sql.jdbcx.db2.DB2DataSource (datadirect driver for DB2) are not bundled with GlassFish.

Joined: 2006-09-13

Yes I do and it is installed

I have added the following Classpath Suffix in the Server Admin Console and restarted the server, but it still does not work


plus the following code works when I run it outside the Glassfish server

try {
catch(Exception e) {

Joined: 2005-07-09

I had to add the IBM DB2 Jars to the /lib or /domains/domain1/
directory to get GlassFish to see the libraries. (We didn't want to pay for Data Direct drivers). Here is the snippet of domain.xml for DB2 configuration as you must also force the driver in Type 4 mode and change the parameter names to get it to work. copy the below in your resources section and edit accordingly:

The configuration parameters are basically default otherwise. For use behind firewalls you have to change the pool setting to be more aggressive to avoid consistent disconnect exceptions. For example, change resize quantity to be equal to max size. We worked with the GlassFish team to figure out the firewall issues. GlassFish version 2 has a much improved pooling mechanism and you may not need the more agressive configurations.

Joined: 2006-09-13

Thank you very much!!!

Your solution works perfectly.

Joined: 2007-08-10

For me DriverType 2 is working fine on Windows, following the next steps:

Need first to install DB2 client runtime

Then setup a tcp node remote and db

db2cmd /c /w /i db2 catalog tcpip node dbInstance remote hostname server 50000 remote_instance dbInstance

db2cmd /c /w /i db2 catalog db DB2MyDB as DB2MyDB at node dbInstance authentication server


Type 2

Joined: 2007-10-23

We cant use type 2. We need to use type 4. Also we are running Linux not Windows.

Joined: 2003-06-13

As i mentioned in the other post, you can use the type 4 driver unless you need XA support (unless the 9.x versions added it), you just need to specify the drivertype-4