Thanks Konstantin.  I made the change locally, slightly different than what I 
suggested.  I performed some load tests and called the now public restart() 
method.  I didn't encounter any exceptions and the pools reset as expected.

This is my work-around though.  

How do you reset or resize connection pools?

    public synchronized void close() throws SQLException {
        if (!restarting) {    // bth new check
            closed = true;
        }
        GenericObjectPool oldpool = connectionPool;
        connectionPool = null;
        dataSource = null;
        try {
            if (oldpool != null) {
                oldpool.close();
            }
        } catch(SQLException e) {
            throw e;
        } catch(RuntimeException e) {
            throw e;
        } catch(Exception e) {
            throw new SQLNestedException("Cannot close connection pool", e);
        }
    }


    /**
     * Not used currently
     */
    protected boolean restarting = false;  // bth new

    public void restart() {
        try {
                restarting = true;  // bth new
                try {
                        close();
                } finally {
                        restarting = false;  // bth new
                }
        } catch (SQLException e) {
            log("Could not restart DataSource, cause: " + e.getMessage());
        }
    }


Thanks,
 
Brooke Hedrick
Lead Web Administrator
brooke.hedr...@rainhail.com
Tel: 515.559.1322
Cel: 515.314.8953


-----Original Message-----
From: Konstantin Kolinko [mailto:knst.koli...@gmail.com] 
Sent: Thursday, May 31, 2012 8:19 AM
To: Tomcat Users List
Subject: Re: Question about resetting datasources and changes to the 
BasicDataSource.close() method

2012/5/30 Hedrick, Brooke - 43 <brooke.hedr...@rainhail.com>:
>(...)
>
> So far, my options point to making changes to the BasicDataSource to provide 
> a way to set closed=false or make the private method below public with a 
> change to set closed=false.
>
>    /**
>     * Not used currently
>     */
>    private void restart() {  // change to public  -bth
>        try {
>            close();
>            closed = false;  // new line added here -bth
>        } catch (SQLException e) {
>            log("Could not restart DataSource, cause: " + 
> e.getMessage());
>        }
>    }
>

Just a note:

If you want this change to be in the code, you have to ask on the Apache 
Commons DBCP project.

Tomcat repacks released versions of Commons Pool and Commons DBCP as they are, 
only using an automated string replacement to change the package name.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to