You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by N Tapas Kumar Choudhury <ta...@rediffmail.com> on 2004/07/20 10:15:44 UTC

Problem in ConnectionPooling

Hi All,

We are using a connection pool in Tomcat using commons dbcp 
classes
DriverAdaperCPDS (with com.sybase.jdbc2.jdbc.SybDriver class from 
sybase)
and SharedPoolDataSource.

If there is some network problem between tomcat 4.x and sybase
12.5., the code hangs at this line:

Connection con = datasource.getConnection()

i.e. we neither get back any connection object nor any 
exception.

Pasted below is the code we use to create a connection pool and 
get back the connection.

     public static void setConnection() throws Exception
     {
         DriverAdapterCPDS cpds = new DriverAdapterCPDS();
         cpds.setDriver("com.sybase.jdbc2.jdbc.SybDriver");
         cpds.setUrl("jdbc:sybase:Tds:<IP>:<port>/<database>");
         cpds.setUser(<username>);
         cpds.setPassword(<password>);

         SharedPoolDataSource tds = new SharedPoolDataSource();
         tds.setConnectionPoolDataSource(cpds);
         tds.setMaxActive(10);
         tds.setMaxWait(50);
    }

     public static Connection getConnection() throws Exception
     {
         Connection conn = null;
         try
         {
             conn = ds.getConnection();
         }
         catch(Exception e)
         {
             e.printStackTrace();
         }

         return conn;
     }


The above code, however works fine if used within a standalone 
java application.

Any ideas why should the above not work for a tomcat hosted 
application?

Regards,
Tapas

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org