If it were me, I would create a seperate observer thread to watch for
IDLE connections.
You said it yourself: the state of the connection in the pool remains
open. Your fundemental problem,
I believe, is state management.
This thread has one job, to check the state of the connections and if
the connection gets closed,
then take some action. With this method however; you still have the
problem of recovery.
Another way to go is have the observer thread, at defined intervals,
send messages on each connection to alyaws keep them
open. e.g., every 10 minuets for each idle connection, do this
connection.setAutoCommit(true);
Hope this helps,
Mike
Lindsay, William (USPC.PCT.Hopewell) wrote:
> We''ve implemented the ConnectionPool code from Marty Halls book
>http://www.coreservlets.com. In our production environment we connect to Oracle
>through a Firewall. So the pooled connections are
> actually being proxied.
>
> If the connection is IDLE for an unspecific time, the firewall closes the connection
>to Oracle, but the STATE of the Connection in the Pool is OPEN. So when we go to do a
>createStatement() the result
> is SQLException write socket error rest by Peer.
>
> Anyway....I'd like to add this code to the ConnectionPool.java class and on the
>createStatement() do a try. If encountering SQLException I would call the method
>below passing in the orphaned
> connection.
>
> This code can only be tested in the firewalled environment, so I wanted to see if
>anyone had any comments
>
> /**
> restoreConnection method is used when the firewall
> closes an IDLE connection
> */
> public synchronized Connection restoreConnection(Connection conn)
> throws SQLException {
>
> try {
> conn.close(); //free any resources still lying around
> } catch (SQLException e){
> } finally {
> busyConnections.removeElement(conn); //vector of in-use connections
> conn = null; // goodbye - you are the weakest link
> }
>
> return getConnection(); // creates a connection in the background adding it to
>busyConnections vector
> }
>
> Thanks
>
> Bill
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html