spring - release db connections in standalone application -
i working on standalone application using spring/jpa , trying release database resources used.
in web application using tomcat example, shutdown server, , way, let tomcat manage resources.
but in standalone app, have take care this, use runtime.getruntime().addshutdownhook "catch" shutdown event , call ((classpathxmlapplicationcontext) context).close();, this:
runtime.getruntime().addshutdownhook(new thread() { @override public void run() { ((classpathxmlapplicationcontext) context).close(); }
it works exception in stacktrace if thread using connection. wondering if there option? maybe getting list of open transactions , force them rollback?
i believe need implement this , inside destroy method, retrieve datasource , call close method or similar. i'm assuming have few things when shutdown application.
i can't quite right method name don't know using datasource.
Comments
Post a Comment