简体   繁体   English

Derby 网络服务器 - 接受来自多个主机的连接 - derby.drda.host

[英]Derby Network Server - Accept connections from multiple hosts - derby.drda.host

Derby documentation says德比文档

derby.drda.host=hostname derby.drda.host=主机名

The property listens to a host for network connections ie accepts connections from them.该属性侦听主机的网络连接,即接受来自它们的连接。 If 0.0.0.0 is specified, connections from any host is accepted.如果指定了 0.0.0.0,则接受来自任何主机的连接。

Now, I have three remote computers, hostA , hostB , hostC .现在,我有三台远程计算机, hostAhostBhostC

  • My derby server is running on hostA .我的德比服务器在hostA上运行。
  • I want derby server to listen for connections from hostA , hostB , hostC我希望德比服务器侦听来自hostAhostBhostC

So, I wrote所以,我写了

props.setProperty("derby.drda.host", "hostA hostB hostC");

However, this does not work.但是,这不起作用。 Is there some other way ?还有其他方法吗?

Edit:编辑:

When I set the property as当我将属性设置为

props.setProperty("derby.drda.host" , "hostA");

then hostB and hostC are not able to connect to server.然后hostBhostC无法连接到服务器。 They get below exception他们得到以下例外

java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server hostA on port 8,888 with message Connection refused: connect. java.sql.SQLNonTransientConnectionException:java.net.ConnectException:连接到端口 8,888 上的服务器 hostA 时出错,消息连接被拒绝:连接。

However, when I set property as但是,当我将属性设置为

props.setProperty("derby.drda.host" , "0.0.0.0");

then all hosts ( hostA , hostB , hostC ) are able to connect to the server.然后所有主机( hostAhostBhostC )都能够连接到服务器。

I believe you've misunderstood what this property is used for.我相信你误解了这个属性的用途。 This is so that you can tell Derby on which IP of the server to accept connections, if you have multiple network interfaces.如果您有多个网络接口,这样您就可以告诉 Derby 在服务器的哪个 IP 上接受连接。 (A lot of servers have more than one network card, or are connected to several networks at the same time and thus have several IP-s). (很多服务器有多个网卡,或者同时连接到多个网络,因此有多个IP)。

The default setting of 0.0.0.0 means that it should accept any connection being requested on any of the server's IP-s.默认设置0.0.0.0意味着它应该接受在任何服务器 IP-s 上请求的任何连接。 If you set this value to something other than 0.0.0.0 , it will listen just for connections targeting just that IP.如果您将此值设置为0.0.0.0以外的值,它将只侦听针对该 IP 的连接。

This does not limit the client connections based on their IP.这并不限制根据IP的客户端连接。

I believe you need to have the following set:我相信你需要有以下设置:

System.setProperty("derby.drda.startNetworkServer", "true");

In order to start Derby as a network server (and not just run it in the JVM, as I believe the default behaviour was).为了将 Derby 作为网络服务器启动(而不仅仅是在 JVM 中运行它,因为我相信默认行为是这样)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM