Connect to Java DB server (Derby) from network
<p>I have used the following code to start the Java DB server:</p>

<pre><code>System.setProperty("derby.drda.startNetworkServer", "true");
    try {
        NetworkServerControl serverControl = new NetworkServerControl();
        serverControl.start(new PrintWriter(System.out, true));
    } catch (Exception e) {
        e.printStackTrace();
    }
</code></pre>

<p>I can connect to the database on the local PC using the URL:</p>

<pre><code>String dbURLTable = "jdbc:derby://localhost:1527/Tables;create=true;user=Gen;password=YZG";
</code></pre>

<p>But when I try to connect to it on LAN (Firewall disabled) I use the following URL:</p>

<pre><code>String dbURLTable = "jdbc:derby://192.168.1.105:1527/Tables;create=true;user=Gen;password=YZG";
</code></pre>

<p>Yet the other PC cannot connect to this database, what's the problem?
The error I'm getting is:</p>

<pre><code>java.sql.SQLNonTransientConnectionException: java.net.ConnectException : Error connecting to server 192.168.1.106 on port 1,527 with message Connection refused: connect.
    at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
    at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
    at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:270)
    at Admin.CreateTables.CreateT(CreateTables.java:188)
    at Admin.CreateTables.run(CreateTables.java:13)
    at java.lang.Thread.run(Thread.java:745)
Caused by: ERROR 08001: java.net.ConnectException : Error connecting to server 192.168.1.106 on port 1,527 with message Connection refused: connect.
    at org.apache.derby.client.net.NetAgent.&lt;init&gt;(Unknown Source)
    at org.apache.derby.client.net.NetConnection.newAgent_(Unknown Source)
    at org.apache.derby.client.am.ClientConnection.&lt;init&gt;(Unknown Source)
    at org.apache.derby.client.net.NetConnection.&lt;init&gt;(Unknown Source)
    at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl.newNetConnection(Unknown Source)
    ... 6 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at java.net.Socket.connect(Socket.java:538)
    at java.net.Socket.&lt;init&gt;(Socket.java:434)
    at java.net.Socket.&lt;init&gt;(Socket.java:211)
    at javax.net.DefaultSocketFactory.createSocket(SocketFactory.java:271)
    at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
    at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 11 more
</code></pre>