commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [DBUtils] newbie qs
Date Sat, 24 Apr 2004 02:58:13 GMT
Jaime Garza wrote:

>I have used a combination of commons DBCP and commons pool before.  Here
>is an example, with a different driver...
>
>Class.forName("org.hsqldb.jdbcDriver");
>GenericObjectPool connectionPool = new GenericObjectPool(null);
>DriverManagerConnectionFactory connectionFactory = new
>DriverManagerConnectionFactory("jdbc:hsqldb:data/generation", "sa", "");
>PoolableConnectionFactory poolableConnectionFactory = new
>PoolableConnectionFactory(connectionFactory, connectionPool,
>null,null,false,true);
>DataSource dataSource = new PoolingDataSource(connectionPool);
>  
>
Code like the above certainly works, but might be considered by some to 
be too complex.  An alternative to consider would be to use the 
org.apache.commons.dbcp.BasicDataSource class, which is configured very 
simply via JavaBeans properties.  The Javadocs for this class document 
all the settings.

FYI, this is what Tomcat uses under the covers to provide connection 
pooling.

Craig




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


Mime
View raw message