File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes A problem in Connection pool design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "A problem in Connection pool design" Watch "A problem in Connection pool design" New topic

A problem in Connection pool design

Sylven Yip
Ranch Hand

Joined: Aug 30, 2007
Posts: 42
i try to design a Connection pool by Dynamic Proxy.
when the pool user invoke conn.close() method,with Dynamic Proxy,the Connection pool can just recycle the Connection instead of close the Connection.

the pool user call:

to get a Proxy Connection Object,and finish some SQL operation,and then he invoke
the Connection pool set the inUse flag of this conneciton object into false,in this way, the pool can return the free Connection judge by the inUse flag which is false;
if the flag is false,the Proxy hold up all the method,an the user can not use this connection anymore;

now there is another user,he call:

if unfortunately,the object conn2 refer to is the same as conn1 refer to.
the pool set the flag into true,and the proxy cancel hold up the method invocation.
then the problem occur,in this time,the refer variable 'conn1' can use the connection object again!
so,who can i break the refer between refer conn1 and the connection object?
or some other way I can do in the Proxy class?
thank you!
I agree. Here's the link:
subject: A problem in Connection pool design
It's not a secret anymore!