You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by lydie soler <so...@hotmail.com> on 2004/11/30 15:34:18 UTC
Create Serializable DataSource and DataSourceFactory
Hi,
I am quite new at DBCP. For the moment I am using the classes
BasicDataSource and BasicDataSourceFactory. But they are not
serializable.... and I would need them to be...
Has anyone developped a serializable version? The behaviour of these classes
is just perfect for me. So If possible I would prefer not rewrite them
Thanks for your help
Lydie
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: Create Serializable DataSource and DataSourceFactory
Posted by Craig McClanahan <cr...@gmail.com>.
It's not possible to make BasicDataSource serializable, because the
underlying JDBC "Connection" objects that it holds are not
serializable. So, that begs the question of why you care about this.
The only reason I can think of is that you want to store such an
object in session scope in a web application. If so, you might want
to think about using appication scope instead (and share the pool
across all your users), or use the JNDI-accessible JDBC data sources
that are provided by your server. For example, Tomcat uses Commons
DBCP (and the BasicDataSource) as its implementation of this feature:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
Other servers have different ways to configure these data sources, but
the programming examples shown on these pages will be portable.
Craig
On Tue, 30 Nov 2004 14:34:18 +0000, lydie soler <so...@hotmail.com> wrote:
> Hi,
>
> I am quite new at DBCP. For the moment I am using the classes
> BasicDataSource and BasicDataSourceFactory. But they are not
> serializable.... and I would need them to be...
> Has anyone developped a serializable version? The behaviour of these classes
> is just perfect for me. So If possible I would prefer not rewrite them
>
> Thanks for your help
>
> Lydie
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org