De :Steve Hoffman (steveh@orbitz.com)
Objet :Poolman 2.1-b1 Prepared Statement Caching BUG
and Fix
Groupes de discussion :comp.lang.java.databases
View: (This is the only article in this thread) |
Original Format
Date :2001-12-19 13:24:31 PST
There is a bug in Poolman 2.1-b1 prepared statement caching
which is enabled by default. If the skimmer thread
closes down a connection that has a prepared statment
cached,
the next time you go looking for that prepared statment you
get back a reference to an expired connection (which,
of course,
will fail out).
In JDBCPool.java change expire() to include the block of
code marked after +smh. It's not the best code in
the world, but then I've only been looking at this code
a short time.
/** Closes a physical database connection. */
protected void expire(Object o) {
try {
PoolManConnection pcon = (PoolManConnection) o;
pcon.removeConnectionEventListener(this);
try {
pcon.commit();
// ++smh 12/18/01 - On connection
expire, must remove any cached prepared
statements
// from jdbc pool cache. There's prob.
a more efficient way of doing
this, but
// for now, brute force will work
nicely since this really happens when
the skimmer
// thread cleans up (or validation
fails) which shouldn't be that often.
if (info.isPoolPreparedStatements()) {
Iterator i =
preparedStatementPool.values().iterator();
while (i.hasNext()) {
List l = (List)i.next();
if (l != null) {
Iterator j = l.iterator();
while (j.hasNext()) {
PreparedStatement ps =
(PreparedStatement)j.next();
if
(pcon.getPhysicalConnection().equals(ps.getConnection())) {
debug("Removing: " + ps + "
from prepared statment cache because
the connection that owns it is closing.");
closeStatement(ps);
l.remove(ps);
}
}
}
}
}
} catch (SQLException se) {
}
pcon.close();
} catch (Exception e) {
}
removeFromTags(o);
o = null;
}
Good luck. If anybody knows the maintainer, please
pass this on
since I can't seem to reach him (could be the holidays).
Steve
Logged In: YES
user_id=490744
Steve,
I am about to patch my poolman (version 2.1.b1) but cant
find the method removeFromTags() anywhere. Is that an
addition of yours?
//Ratze