I want to use HyperSQL as an in-memory database for integration tests of a Java – JDBC application.
If I try the following:
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);");
I get:
java.sql.SQLException: Table not found: foo in statement [Insert into bar]
I thought there was a way for HSQL to dynamically generate the tables when used as an in-memory database, but I can’t seem to find it in the documentation.
Why are you executing a query for an INSERT? That won’t return a
ResultSet.You ought to
executeUpdate()There’s nothing “automatic” in HSQL. You might be thinking of Hibernate and its hbm2ddl.