【发布时间】:2011-10-05 13:23:10
【问题描述】:
我想将 HyperSQL 用作内存数据库,用于 Java - JDBC 应用程序的集成测试。
如果我尝试以下操作:
Properties props = new Properties();
props.put("user", "sa");
props.put("password", "");
Class.forName("org.hsqldb.jdbcDriver");
Connection cn = DriverManager.getConnection("jdbc:hsqldb:mem://localhost", props);
Statement st = cn.createStatement();
st.executeUpdate("Insert into foo (bar) values (10);");
我明白了:
java.sql.SQLException: Table not found: foo in statement [Insert into bar]
我认为 HSQL 有一种方法可以在用作内存数据库时动态生成表,但我似乎无法在文档中找到它。
【问题讨论】:
-
您的数据库中是否已有
foo?如果它不存在,它如何知道它的架构?
标签: java jdbc integration-testing hsqldb in-memory-database