提交 59360715 authored 作者: Thomas Mueller's avatar Thomas Mueller

The DbStarter servlet context listener now starts the server before opening a…

The DbStarter servlet context listener now starts the server before opening a connection, so that connecting using the server mode works.
上级 e64620dd
...@@ -37,9 +37,6 @@ public class DbStarter implements ServletContextListener { ...@@ -37,9 +37,6 @@ public class DbStarter implements ServletContextListener {
String user = getParameter(servletContext, "db.user", "sa"); String user = getParameter(servletContext, "db.user", "sa");
String password = getParameter(servletContext, "db.password", "sa"); String password = getParameter(servletContext, "db.password", "sa");
conn = DriverManager.getConnection(url, user, password);
servletContext.setAttribute("connection", conn);
// Start the server if configured to do so // Start the server if configured to do so
String serverParams = getParameter(servletContext, "db.tcpServer", null); String serverParams = getParameter(servletContext, "db.tcpServer", null);
if (serverParams != null) { if (serverParams != null) {
...@@ -47,9 +44,11 @@ public class DbStarter implements ServletContextListener { ...@@ -47,9 +44,11 @@ public class DbStarter implements ServletContextListener {
server = Server.createTcpServer(params); server = Server.createTcpServer(params);
server.start(); server.start();
} }
// To access the database in server mode, use the database URL: // To access the database in server mode, use the database URL:
// jdbc:h2:tcp://localhost/~/test // jdbc:h2:tcp://localhost/~/test
conn = DriverManager.getConnection(url, user, password);
servletContext.setAttribute("connection", conn);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论