Interesting. While I'm not doing this from Struts, I've just worked on using DB2's internal connection pool from standalone code. Perhaps this will help. I got this information from an IBMer, although even he never pointed me at supporting documentation:
------------------------------------------------------------------------
import java.sql.Connection;


import COM.ibm.db2.jdbc.DB2DataSource;

public class DB2ConnectTest {


public static void main(String[] args) throws Exception {


  DB2DataSource datasource = new DB2DataSource();
  datasource.setPassword("user");
  // Must use App Driver -- do so by not setting server name or port
  datasource.setDatabaseName("YOURDB");
  datasource.setUser("password");

  final int NUM_CONNS = 10;
  for (int i = 1; i <= NUM_CONNS; i++) {
   long start = System.currentTimeMillis();
   Connection conn = datasource.getConnection();
   long end = System.currentTimeMillis();
   conn.close();
   System.out.println("Get Connection took #" + i + ": " + (end - start));
  }

}

}
--------------------------------------------------------------------
His assertion and my experience show that this does use a Connection Pool.

So... while I've never tried to translate this into Struts, I can see a few things that are different that you could try. Namely, the class of the DataSource implementation and trying to set the "name" property (maybe instead of the "url" property).

Also, I specifically asked about DB2 v7.2. I know v8 has some more sophisticated capabilities (like a Type 4 JDBC driver), so there may be a slightly different answer if you are on that version.

Good luck, and please reply back here if you get it working.
Doug

Eric SCHULTZ wrote:

Good morning...

I'm having an impossible time getting a pool of connections to a DB2
database going.

I've gotten a single connection to work using the old method
(DriverManager.register, DriverManager.getConnection, ...) but I can't seem
to do it by describing the datasource in struts-config.xml and calling
getDataSource().

Here's the code that works (in a bean):
        DriverManager.registerDriver(new COM.ibm.db2.jdbc.app.DB2Driver());
        Connection conn = DriverManager.getConnection("jdbc:db2:DB2Test",
"user", "password");

I've tried a whole bunch configurations in struts-config.xml, for example:
        <data-source key="CIS"
type="COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource">
                <set-property property="driverClass"
value="COM.ibm.db2.jdbc.app.DB2Driver" />
                <set-property property="url" value="jdbc:db2:DB2Test" />
                <set-property property="user" value="user" />
                <set-property property="password" value="password" />
                <set-property property="maxActive" value="10" />
                <set-property property="maxWait" value="5000" />
                <set-property property="defaultAutoCommit" value="false" />
        </data-source>

and then in my Action I call:
        CISCustomerLookup ccl = new CISCustomerLookup(getDataSource(req,
"CIS").getConnection());

Where ccl is my bean and to shield it from the Struts layer I pass the
connection it should use for the lookup.  But it doesn't work.  The latest
error I recieved is the following:
        javax.servlet.ServletException: [IBM][JDBC Drvier] CLI0615E Error
receiving from...

I've also recieved messages alluding to no suitable driver available.  And
when I check the Tomcat log I have often had a situation where the
ActionServlet was marked unavailable due to a problem creating the
datasource when I deployed the war.

 I've also tried the net driver (COM.ibm.db2.jdbc.net.DB2Driver) with
similar results.

Help me please!!! Any working examples would be most apprciated.

Eric Schultz
Technical Leader
Conseiller Technique
Elix
Specialist in interactive business solutions
Specialiste en solutions d'affaires interactives
14 Commerce Place, 5th floor
Nun's Island, QC  H4E 1T5
t: 514 768-1000
f: 514 768-7680


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to