I apologize to the list, the last message got truncated and sent. I hit return
twice while editing in Yahoo (normally edit off-line).
OK - for the database leak.
Use try / catch / finally blocks around all connection code (Hibernate or
otherwise). I think someone posted boilerplate code to the list not too long
ago.
// try catch finally pseudocode
// review and use at your own risk
Session session = HibernateUtil.getSessionFactory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
// do your database stuff here
tx.commit();
}
catch (Exception e) {
if (tx != null) {
tx.rollback();
}
// do something meaningful here - log and recover
}
finally {
if (session != null) {
session.close();
}
The Hibernate documentation advocates using filters to get and close sessions,
especially if you're using a secondary cache.
Secondly, there have been some permgen leaks fixed in the latest versions of
the MySQL JDBC driver. Make sure you're using 5.1.12 (latest version). 5.1.11
fixed a permgen leak from java.util.Timer.
Here's the permgen leak bug notation:
- Fixed Bug#36565 - permgen leak from
java.util.Timer. Unfortunately no great fix exists that lets us
keep the timer shared amongst connection instances, so instead
it's lazily created if need be per-instance, and torn down when
the connection is closed.
Again, sorry for the earlier message.
. . . . just my two cents
/mde/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]