You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Johan Compagner <jc...@j-com.nl> on 2001/02/07 15:21:44 UTC

GenericConnection.close() -> Test before setting before resetting to default.

Hi,

I use the JDBCODBC driver at this time to a Access DB (just in the
development fase)
And i have build in a PreparedStatement Connection pool.
So that connection.preparedStatement returns a pooled one instead of
creating new ones all
the time. in the Close() of my GenericPreparedStatement class i return it to
the pool of the
GenericConnection.
But when the GenericConnection is closed. the close() method of
GenericConnection
just set's the default values like this: (and for readonly, ect ect)

 try
 {
   conn.setCatalog(this.catalog);
 }
 catch (SQLException e)
 {
  ;
 }

The problem is that when i set the Catalog even it is not changed i can't
use my
PreparedStatements anymore, the next time i use one after thet setCatalog
call i get
a exception: Function Sequence Error

So what i did for all the default params is first test it if it is changed:

 try
 {
  if(!conn.getCatalog().equals(this.catalog))
  {
   conn.setCatalog(this.catalog);
  }
 }
 catch (SQLException e)
 {
  ;
 }

Can struts do the same?
Why resetting a default property if it isn't changed?

I attached my GenericConnection and all the classes that are added and
changed for the
preparedStatement Pool. Maybe this is something for struts?

By Default nothing is cached or pooled because the CacheStatements boolean
of the
GenericDataSource i added is false.
It would be nice if i could set that property in the struts-config.xml file
in the datasource section.


Johan