I have a standalone Java application that uses Hibernate to manage SQL connections. I work with a MySQL database and I ensure that all sessions are closed when the main() method exits.
My code goes something like this:
public static void main(String[] args) {
logger.info("Starting app");
App instance = new App();
try {
instance.run();
} catch (Exception e) {
logger.error("failed to complete run", e);
} finally {
HibernateUtil.closeCurrentSession();
}
logger.info("Finished run");
}
Right now, everytime this main method exits, I see a log in my sql error logs saying: [Warning] Aborted connection 41533470 to db: 'user' user: 'some_user' host: 'some_ip_address_here' (Got an error reading communication packets)
Does this mean that MySQL manually kills it? If so, how do I close my MySQL connection gracefully? If I can recall my Hibernate correctly, closing sessions just put them back into the pool of sessions... I'm not sure how to entirely tell Hibernate to release its connection with MySQL.
EDIT: I am using C3P0 for this one - sorry forget to mention earlier. My connections do close but it's just that I get the [Warning] error on my mysql.err logs. I don't like seeing these types of warnings because clearly there's something wrong.