提交 277f2643 authored 作者: Thomas Mueller's avatar Thomas Mueller

The DbStarter now closes all connections to the configured database

上级 945c201f
...@@ -69,14 +69,20 @@ public class DbStarter implements ServletContextListener { ...@@ -69,14 +69,20 @@ public class DbStarter implements ServletContextListener {
} }
public void contextDestroyed(ServletContextEvent servletContextEvent) { public void contextDestroyed(ServletContextEvent servletContextEvent) {
if (server != null) { try {
server.stop(); conn.createStatement().execute("SHUTDOWN");
server = null; } catch (Exception e) {
e.printStackTrace();
} }
try { try {
conn.close(); conn.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (server != null) {
server.stop();
server = null;
} }
}
} }
...@@ -234,6 +234,10 @@ class WebSession { ...@@ -234,6 +234,10 @@ class WebSession {
return shutdownServerOnDisconnect; return shutdownServerOnDisconnect;
} }
/**
* Close the connection and stop the statement if one is currently
* executing.
*/
void close() { void close() {
if (executingStatement != null) { if (executingStatement != null) {
try { try {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论