Question

When I print the I.P. address of the system using InetAddress.getLocalHost(), I get user-VAIO/192.168.1.3 .
Now, when I connect to derby using jdbc:derby://localhost:1527/mydatabase;create=true, it connects without any errors
but when I connect the same using jdbc:derby://192.168.1.3:1527/mydatabase;create=true,
it fails giving me the following exception:-
java.net.ConnectException : Error connecting to server 192.168.1.3 on port 1527 with message Connection refused: connect.

Any help will be appreciated.

Was it helpful?

Solution

When you start your Derby Network Server, you provide a value for the '-h' argument. You might not realize you are doing this, if you are using the packaged StartNetworkServer.bat file, but look inside the batch file, and you will see the -h argument there.

The batch file comes provided with the syntax '-h default' when you download Derby from the Apache website.

But you can change that, to say, for example, '-h 192.168.1.3', and then your Derby Network Server will accept connections that specify 'jdbc:derby://192.168.1.3/my/database'.

Note that if you want to accept such connections from other computers on the network, you will also have to adjust your Windows Firewall rules, as by default it will prevent such connections.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top