简体   繁体   中英

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

Derby documentation says

derby.drda.host=hostname

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.

Now, I have three remote computers, hostA , hostB , hostC .

  • My derby server is running on hostA .
  • I want derby server to listen for connections from hostA , hostB , hostC

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. They get below exception

java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server hostA on port 8,888 with message Connection refused: connect.

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.

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. (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).

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. If you set this value to something other than 0.0.0.0 , it will listen just for connections targeting just that IP.

This does not limit the client connections based on their 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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