Skip to main content

DB2 Connection Pool

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

Server 9.1 (build b41d-beta2)

I am trying to setup connection pool .
DatabaseSource Classname: com.ibm.db2.jcc.DB2Driver
Resource Type: javax.sql.DataSource

I am getting the following error when I click on the Ping button

com.ibm.db2.jcc.DB2Driver 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

Peter

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jimnz111
Offline
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)

jeffreyrodriguez
Offline
Joined: 2007-02-23

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

Check out:
https://glassfish.dev.java.net/javaee5/docs/AG/ablih.html#beamy

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

That should work.

pczurak
Offline
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 com.ibm.db2.jcc.DB2SimpleDataSource
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

jr158900
Offline
Joined: 2005-04-13

have you specified all the environment variables with appropriate values, as directed in
https://glassfish.dev.java.net/javaee5/docs/AG/ablih.html#beanc
Do you have the native library available ?

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

pczurak
Offline
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

/opt/IBM/db2/V8.1/java/db2jcc.jar
/opt/IBM/db2/V8.1/java/db2java.jar
/opt/IBM/db2/V8.1/db2jcc_license_cu.jar
/opt/IBM/db2/V8.1/db2jcc_javax.jar

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

try {
Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
}
catch(Exception e) {
System.out.println(e.toString());
}

byteme
Offline
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.

pczurak
Offline
Joined: 2006-09-13

Thank you very much!!!

Your solution works perfectly.

pmarc
Offline
Joined: 2007-08-10

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

Need first to install DB2 client runtime
"DB2_runtime_lite_ALL_LANG_setup.exe"

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

"DOMAIN.XML"



Type 2

sbeard
Offline
Joined: 2007-10-23

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

lancea
Offline
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