commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <>
Subject Re: DBCP status?
Date Mon, 30 Jun 2003 07:44:33 GMT

> ResultSet rs;
> try {
>     con = magicGetConnection();
>     //stuff
> } catch(...) {
> } finally {
>    try {if (rs!=null){ rs.close(); rs=null; } } catch(Throwable ignore){}
>    try {if (ps!=null){ ps.close(); ps=null; } } catch(Throwable ignore){}
>    try {if (ps!=null){ con.close(); con=null; } } catch(Throwable
> }
> In the above code - I try to use the good practice of try-catch-finally.
> code works great in the testing environment (of course it should fail in
> stress testing in cases it can be done).

There are a lot of good ways to manage resources, but I think it is out of
DBCP scope.
Workarounds in pool can not help in this case too ("try {if (ps!=null){
con.close(); con=null; } } catch(Throwable ignore){}")
 "maxConnections = 1" can better help to find this kind of problems.
Let handle this stuff for JDBC frontends. Is is very easy to implement JDBC
resource management.

I use JDBC API this way at this time:

void method( String arg1, .... ){

   JdbcUtils.executeSQL( "SELECT .....", new Object[]{ arg1 , ...},

    new Callback(){

       public void handle( ResultSet rs ){
                .... handle results ....


There are a lot of opensource frameworks like IBATIS, Voruta,
SpringFramework, ...  DbUtils in sandbox is a minimalist tool for JDBC API
too. It is very easy to learn and use this kind of frameworks, just add
links  to JDBC frontends and it will solve database progamming problems
I prefer pools without workarounds, it can help to find and fix problem. Do
not to hide problems, it solves nothing.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message