You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anthony Martin <An...@TRAMS.com> on 2001/04/16 18:37:59 UTC

Data Connection Pool

I have been very pleased with the Struts framework.  I'm sure this issue has
been dealt with, I'm just not sure how to approach it.

When I leave my database pooled connections open for long periods of time,
there is a possibility that the server will reset.  When this happens, my
database driver keeps the connections open.  If I restart tomcat, I get an
exception regarding the open pooled connection that's already established.
If I kill the java process, I can start up normally.

On Win2k, I can get rid of the startup error completely by making the
minimum number of connections zero.  On FreeBSD, it gets more complicated. I
have not found a way to reliably start up tomcat like I can on Win2k.

Any ideas?  Here's the database portion of my struts-config.xml:

 <data-sources>
  <data-source
   autoCommit="false"
   description="Interbase Data Source"
   driverClass="interbase.interclient.Driver"
   maxCount="4"
   minCount="0"
   url="jdbc:interbase://path/to/database"
   user="username"
   password="password"
  />
 </data-sources>

Anthony

It is by caffeine alone I set my mind in motion.
It is by the Beans of Java that thoughts acquire speed,
the hands acquire shaking, the shaking becomes a warning.
It is by caffeine alone I set my mind in motion.

Re: Data Connection Pool, solution?

Posted by Johan Compagner <jc...@j-com.nl>.
there should be another attribute  in the datasource like this:

    testSql="select * from test"

and GenericConnection has a setTestSql(String) method 
and that test method is executed right before the connections is given to the
request in getConnection()
When it fails it closed and tries another one (or opens another one)
So anyone can decide there own test method/sql statement, because
i don't think there is a common one.

Only some rules must be set:
Must the testSQL string return a result set and must it have one result
if not it is the same as failing?

This would be a nice addition to struts 1.0!

Johan Compagner



>  <data-sources>
>   <data-source
>    autoCommit="false"
>    description="Interbase Data Source"
>    driverClass="interbase.interclient.Driver"
>    maxCount="4"
>    minCount="0"
>    url="jdbc:interbase://path/to/database"
>    user="username"
>    password="password"
>   />
>  </data-sources>
> 
> Anthony
> 
> It is by caffeine alone I set my mind in motion.
> It is by the Beans of Java that thoughts acquire speed,
> the hands acquire shaking, the shaking becomes a warning.
> It is by caffeine alone I set my mind in motion.
> 


Re: Data Connection Pool, solution?

Posted by Johan Compagner <jc...@j-com.nl>.
there should be another attribute  in the datasource like this:

    testSql="select * from test"

and GenericConnection has a setTestSql(String) method 
and that test method is executed right before the connections is given to the
request in getConnection()
When it fails it closed and tries another one (or opens another one)
So anyone can decide there own test method/sql statement, because
i don't think there is a common one.

Only some rules must be set:
Must the testSQL string return a result set and must it have one result
if not it is the same as failing?

This would be a nice addition to struts 1.0!

Johan Compagner



>  <data-sources>
>   <data-source
>    autoCommit="false"
>    description="Interbase Data Source"
>    driverClass="interbase.interclient.Driver"
>    maxCount="4"
>    minCount="0"
>    url="jdbc:interbase://path/to/database"
>    user="username"
>    password="password"
>   />
>  </data-sources>
> 
> Anthony
> 
> It is by caffeine alone I set my mind in motion.
> It is by the Beans of Java that thoughts acquire speed,
> the hands acquire shaking, the shaking becomes a warning.
> It is by caffeine alone I set my mind in motion.
>