我从远程计算机使用H2数据库作为DBMS,因此我启用了从浏览器远程访问,如下所示:
webAllowOthers=true
Run Code Online (Sandbox Code Playgroud)
但是当我尝试从我的java应用程序连接到服务器时,我从H2获得此错误:
remote connections to this server are not allowed
Run Code Online (Sandbox Code Playgroud)
截图:

并且已经在查找代码分析器(错误代码:90117):
REMOTE_CONNECTION_NOT_ALLOWED = 90117
如果不允许远程连接,则尝试从另一台计算机连接到TCP服务器时会引发代码90117的错误.要允许远程连接,请使用选项-tcpAllowOthers启动TCP服务器,如下所示:
java org.h2.tools.Server -tcp -tcpAllowOthers
或者,从应用程序启动服务器时,使用: Server server = Server.createTcpServer(" - tcpAllowOthers"); server.start();
我不明白如何激活tcpAllowOthers,它在.h2.server.properties中不存在?
Tho*_*ler 17
有两种不同的服务器:
jdbc:h2:tcp://localhost/~/test)该文件.h2.server.properties仅用于Web控制台服务器.它只支持webAllowOthers=true.TCP服务器不使用此文件.
要启用对TCP服务器的远程访问,需要使用该选项启动TCP服务器 -tcpAllowOthers.要启动Web控制台服务器(H2控制台工具)和启用了远程连接的TCP服务器,您需要使用:
java -jar h2*.jar -web -webAllowOthers -tcp -tcpAllowOthers -browser
Run Code Online (Sandbox Code Playgroud)
(这也启动浏览器)