commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John McNally <jmcna...@collab.net>
Subject Re: Questions about jdbc2pooldatasource and cpdsadapter
Date Wed, 04 Jun 2003 22:27:35 GMT
I do not plan any api changes that would affect your usage and I do use
the DataSource and backing ConnectionPoolDataSource in a manner similar
to your example and always connecting as the single user.  I have not
noticed any problems.

BasicDataSource uses a Driver to supply the physical connections as
well, so you should be able to use that if you wish.

john mcnally

On Wed, 2003-06-04 at 00:36, hicham ABASSI wrote:
> Hy,
> 
> I have a JDBC driver v1.0. It doesn't implement the Datasource interface.
> This is a Centura SQLBase DB.
> I failout to create a JNDI Datasource in Tomcat because this driver doesn't provide Datasource
object.
> I need to create a Datasource to using it in JSTL sql tags. (<sql:query... )
> 
> i can create datasource in a servletcontextlistener with theses the packages :
>   a..     org.apache.commons.dbcp.cpdsadapter
>   b..     org.apache.commons.dbcp.jdbc2pool
> 
> 
> Here is the theory code :
> 
> ----------------------------------------------------------------------------------------------
> package com.lc.rm.servlets;
> 
> import javax.servlet.*;
> import javax.servlet.http.*;
> import javax.sql.*;
> import org.apache.commons.dbcp.*;
> import org.apache.commons.dbcp.jdbc2pool.*;
> import org.apache.commons.dbcp.cpdsadapter.*;
> import javax.servlet.jsp.jstl.core.*;
> 
> public class ResourceManagerListener implements ServletContextListener {
> 
>     public void contextInitialized(ServletContextEvent sce) {
>     
>     ServletContext application = sce.getServletContext( );
>     
>     DataSource ds = null;
>     
>     try {
>         DriverAdapterCPDS cpds = new DriverAdapterCPDS();    
>         cpds.setDriver(<JdbcDriverClassName>);
>         cpds.setUrl(<jdbcUrl>);
>         cpds.setUser(<username>);
>         cpds.setPassword(<password>);
> 
>         Jdbc2PoolDataSource tds = new Jdbc2PoolDataSource();
>         tds.setConnectionPoolDataSource(cpds);
>         tds.setDefaultMaxActive(10);
>         tds.setDefaultMaxWait(5);
>         tds.setDefaultAutoCommit(false);
>         tds.setDefaultMaxIdle(1);
>         
>         ds = tds;
>     }
>     catch (Exception e) {
>       application.log("Error creating connection pool: ", e);
>     }
>     // Assign this datasource to the default JSTL Datasource
>     Config.set(application, Config.SQL_DATASOURCE, ds);
>   }
>   public void contextDestroyed(ServletContextEvent sce) {
>     ServletContext application = sce.getServletContext( );
>   }
> }
> ------------------------------------------------------------------------------------
>     
> But these packages are not released in the 1.0.
> 
> Are they stable ?
> If not, how to do this with org.apache.commons.dbcp package ?
> 
> I need a Datasource, not a driver.
> The examples show how to create a PoolDatasource or a PoolDriver.
> 
> I regret that i can't create a PoolDatasource with JOCL. is it correct ?
> i see that only PoolDriver can read JOCL file.
> 
> 
>   a.. tomcat 4.1.24
>   b.. commons-dbcp
>   c.. SQLBase 7
>   d.. Windows2000
>   e.. jdk1.4.1_02
> 
> 
> Thanks.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 



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


Mime
View raw message