我写了以下代码:
private static void startH2(){
Server server = null;
try {
server = Server.createTcpServer("-tcpAllowOthers").start();
Class.forName("org.h2.Driver");
Connection conn = DriverManager.
getConnection("jdbc:h2:tcp://localhost/~/test;MODE=PostgreSQL", "sa", "");
} catch (Exception e) {
LOG.error("Error while initialize", e);
}
System.out.println("finish");
}
public static void main(String [] args){
startH2();
}
我运行我的主要方法并看到以下情况:
看起来像Server.createTcpServer
创建新的非守护线程。
但通过 urllocalhost:8082
我看不到 h2 web 控制台(实际结果 - ERR_CONNECTION_REFUSED
)
如何解决这个问题?
附言
我注意到通过 url
http://localhost:9092/
我的浏览器下载了包含奇怪内容的文件:
如果要解码此文本,我会看到以下消息:
版本不匹配,驱动版本为“0”而服务器版本为“15”</p>
我用的是h2版本1.4.182