连接具有远程数据库 [英] connection has a remote Database

查看:109
本文介绍了连接具有远程数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用H2数据库作为远程计算机上的DBMS,因此我启用了从浏览器进行的远程访问,如下所示:

I use H2 Database as DBMS from a remote computer,so I enabled remote access from a browser as follows:

webAllowOthers=true

但是当我尝试从Java应用程序连接到服务器时,我从H2收到此错误:

but when i try to connect to the server from my java application i get this error from H2:

remote connections to this server are not allowed

屏幕截图:

并且已经在使用(错误代码:90117)的代码分析器进行了研究:

And also already looking into the code Analyzer with (Error Code: 90117):

REMOTE_CONNECTION_NOT_ALLOWED = 90117

REMOTE_CONNECTION_NOT_ALLOWED = 90117

如果不允许远程连接,则尝试从另一台计算机连接到TCP服务器时,将引发代码90117的错误.要允许远程连接,请使用-tcpAllowOthers选项启动TCP服务器,如下所示:

The error with code 90117 is thrown when trying to connect to a TCP server from another machine, if remote connections are not allowed. To allow remote connections, start the TCP server using the option -tcpAllowOthers as in:

java org.h2.tools.Server -tcp -tcpAllowOthers

或者,从应用程序启动服务器时,请使用: 服务器服务器= Server.createTcpServer(-tcpAllowOthers"); server.start();

Or, when starting the server from an application, use: Server server = Server.createTcpServer("-tcpAllowOthers"); server.start();

我不知道如何激活 tcpAllowOthers ,它在 .h2.server.properties 中不存在?

I do not understand how to activate the tcpAllowOthers, it does not exist in .h2.server.properties ?

推荐答案

有两个不同的服务器:

  • 用于运行H2控制台工具(GUI工具)的Web控制台服务器.只能通过浏览器访问它.
  • 使用客户端/服务器模式(jdbc:h2:tcp://localhost/~/test)时允许连接使用JDBC的应用程序的TCP服务器
  • the Web Console server that is used to run the H2 Console tool (the GUI tool). It can be accessed by a browser only.
  • the TCP server that allows to connect an application that uses JDBC, when using the client/server mode (jdbc:h2:tcp://localhost/~/test)

文件.h2.server.properties仅用于Web Console服务器.它仅支持webAllowOthers=true. TCP服务器不使用该文件.

The file .h2.server.properties is only used for the Web Console server. It only supports webAllowOthers=true. This file is not used by the TCP server.

要启用对TCP服务器的远程访问,您需要使用选项-tcpAllowOthers启动TCP服务器.要启动启用了远程连接的Web控制台服务器(H2控制台工具),您需要使用:

To enable remote access to the TCP server, you need to start the TCP server using the option -tcpAllowOthers. To start both the Web Console server (the H2 Console tool) and the TCP server with remote connections enabled, you would need to use:

java -jar h2*.jar -web -webAllowOthers -tcp -tcpAllowOthers -browser

(这也会启动浏览器)

这篇关于连接具有远程数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆