You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Thomas Fischer <tf...@apache.org> on 2005/06/26 10:12:18 UTC

closing Datasources at Torque.shutdown()

Hi,

I would like to close DataSources initialized by Torque if 
Torque.shutdown() is called. To do this, I'd like to add a close()-method 
to the interface DataSourceFactory.

Closing works fine for SharedPoolDataSourceFactory and 
PerUserPoolDataSourceFactory. It does not work, however, for 
DataSourceFactories deployed/retrieved via JNDI. This has two reasons:
- First, one does not want to close Pools retrieved via JNDI. Other 
applications might use the same Datasource. Also, because we have not 
deployed the Datasource, we are not responsible for shutting it down.
- Second, even if we have deployed the Datasource, it is very problematic 
to shut it down because the interface DataSource does not have a close() 
method or anything similar. As any DataSource can be deployed, we do not 
know how to shut it down. One might think "See if it is a DBCP Datasource, 
if yes, we know how to shut it down, let's do it" is also no good solution 
because it is a very unintuitive behaviour and can lead to very strange 
errors.

Does anybody have any problems with that, or any suggestions to improve 
the behaviour ?

             Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Re: closing Datasources at Torque.shutdown()

Posted by Thomas Fischer <fi...@seitenbau.net>.



Thomas Vandahl <th...@tewisoft.de> schrieb am 27.06.2005 09:07:39:

> Thomas Fischer wrote:
>
> > Closing works fine for SharedPoolDataSourceFactory and
> > PerUserPoolDataSourceFactory. It does not work, however, for
> > DataSourceFactories deployed/retrieved via JNDI. This has two reasons:
> > - First, one does not want to close Pools retrieved via JNDI. Other
> > applications might use the same Datasource. Also, because we have not
> > deployed the Datasource, we are not responsible for shutting it down.
> > - Second, even if we have deployed the Datasource, it is very
> > problematic to shut it down because the interface DataSource does not
> > have a close() method or anything similar. As any DataSource can be
> > deployed, we do not know how to shut it down. One might think "See if
it
> > is a DBCP Datasource, if yes, we know how to shut it down, let's do it"

> > is also no good solution because it is a very unintuitive behaviour and

> > can lead to very strange errors.
>
> AFAICS, the recommended handling of JNDI DataSources is to leave their
> management to the container. I suggest to implement an empty close()
> method in DataSourceFactory which could be overridden in implementations
> that support closing a DataSource.
>
> Bye, Thomas.

This is also what I have in mind. I need the interface for
DataSourceFactory to define the close() method, and the
JndiDataSourceFactory needs to implement the interface, so the method needs
to be there, but is empty for above reasons.

    Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Re: closing Datasources at Torque.shutdown()

Posted by Thomas Vandahl <th...@tewisoft.de>.
Thomas Fischer wrote:

> Closing works fine for SharedPoolDataSourceFactory and 
> PerUserPoolDataSourceFactory. It does not work, however, for 
> DataSourceFactories deployed/retrieved via JNDI. This has two reasons:
> - First, one does not want to close Pools retrieved via JNDI. Other 
> applications might use the same Datasource. Also, because we have not 
> deployed the Datasource, we are not responsible for shutting it down.
> - Second, even if we have deployed the Datasource, it is very 
> problematic to shut it down because the interface DataSource does not 
> have a close() method or anything similar. As any DataSource can be 
> deployed, we do not know how to shut it down. One might think "See if it 
> is a DBCP Datasource, if yes, we know how to shut it down, let's do it" 
> is also no good solution because it is a very unintuitive behaviour and 
> can lead to very strange errors.

AFAICS, the recommended handling of JNDI DataSources is to leave their 
management to the container. I suggest to implement an empty close() 
method in DataSourceFactory which could be overridden in implementations 
that support closing a DataSource.

Bye, Thomas.


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org