The code synchronizes on a new object each time - that's like no
synchronization at all. You probably want: synchronized
(ContextInfo.class) { ... }
> What I'm trying to do is get a connection at the beginning of the
> request and return it to the pool at the end of the request.
The rest of the code you sent looks good. But you may want to log when
a connection was made, and when it was returned:
log.debug("Pool created");
private static int openConnectionCount;
log.debug("Connection opened: " + ++openConnectionCount);
log.debug("Connection closed: " + --openConnectionCount);
If the count goes higher than 5 you know there is a problem in your application.
Regards,
Thomas