这样的事情应该有效
Server server = null;
try {
server = Server.createTcpServer("-tcpAllowOthers").start();
Class.forName("org.h2.Driver");
Connection conn = DriverManager.
getConnection("jdbc:h2:tcp://localhost/~/stackoverflow", "sa", "");
System.out.println("Connection Established: "
+ conn.getMetaData().getDatabaseProductName() + "/" + conn.getCatalog());
} catch (Exception e) {
e.printStackTrace();
输出为Connection Established:H2 / STACKOVERFLOW
这已通过h2-1.4.184测试