DBCP removeAbandoned not working!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

DBCP removeAbandoned not working!

Joe Hansen
hi all,

I am using DBCP 1.2.1. Why is the abandoned connection NOT returned after 5
seconds?

Please help.
Thanks,
Joe.

The output of the following program is as follows:
<output>
Loading underlying JDBC driver.
Creating connection 1.
AbandonedObjectPool is used
(org.apache.commons.dbcp.AbandonedObjectPool@21b6d)
   LogAbandoned: false
   RemoveAbandoned: true
   RemoveAbandonedTimeout: 300
Creating connection 2.
org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool
exhausted
</output>

<code>
import java.sql.Connection;
import javax.sql.DataSource;
import java.util.Properties;
import org.apache.commons.dbcp.BasicDataSourceFactory;


public class ManualPoolingDriverExample2 {

    public static void main(String[] args) {
        System.out.println("Loading underlying JDBC driver.");
        Properties dataSourceProperties = new Properties();
        dataSourceProperties.setProperty("factory",
"org.apache.commons.dbcp.BasicDataSourceFactory");
        dataSourceProperties.setProperty("driverClassName",
"com.progress.sql.jdbc.JdbcProgressDriver");
        dataSourceProperties.setProperty("url",
"jdbc:jdbcprogress:T:localhost:9199:test");
        dataSourceProperties.setProperty("username", "joe");
        dataSourceProperties.setProperty("password", "joe1");
        dataSourceProperties.setProperty("maxActive", "1");
        dataSourceProperties.setProperty("maxWait", "10000"); // wait for 10
secs
        dataSourceProperties.setProperty("removeAbandoned", "true");
        dataSourceProperties.setProperty("logAbandoned", "false");
        dataSourceProperties.setProperty("removeAbandonedTimeout", "5"); //
return abandonded connections after 5 secs

        try {
        DataSource dataSource =
BasicDataSourceFactory.createDataSource(dataSourceProperties);

            Connection conn = null;

            System.out.println("Creating connection 1.");
            conn = dataSource.getConnection();
            System.out.println("Creating connection 2.");
            conn = dataSource.getConnection();
            System.out.println("Done creating connections.");
        } catch (Exception ex) {
        ex.printStackTrace();
        }
    }

}
</code>

_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]