title: How to change port that HSQLDB server listens on
body: <p>I am starting a HSQLDB server programmatically, however I am getting port conflicts when I try an run the HSQLDB server in conjunction with a web application that I am developing. I get the following error on the webapp side</p>
  
  <pre><code>java.util.concurrent.ExecutionException: java.net.BindException: Address already in use: JVM_Bind
  </code></pre>
  
  <p>&amp; I get this error on the database server side:</p>
  
  <pre><code>org.hsqldb.HsqlException: Client driver version greater than '-1852.-79.-80.-35' is required.  HSQLDB server version is '2.3.2'
          at org.hsqldb.error.Error.error(Unknown Source)
          at org.hsqldb.server.ServerConnection.init(Unknown Source)
          at org.hsqldb.server.ServerConnection.run(Unknown Source)
          at java.lang.Thread.run(Thread.java:745)   
  </code></pre>
  
  <p>I'm not sure why I get this error. However, when I looked at the ports used by the webapp and HSQLDB, I found that they both use 9001 so I assume the issue is to do with conflicting ports and not about HSQLDB versions. However, I'm not certain about that.</p>
  
  <p>I understand that the default port number used by HSQLDB is 9001 and I've tried to change this with the following code by setting the port to be used to 9137.</p>
  
  <pre><code>    public void startDBServer() {
      HsqlProperties props = new HsqlProperties();
      props.setProperty("server.database.0", "file:" + dbLocation + "webappdb;");
      props.setProperty("server.dbname.0", "webappdb");
      props.setProperty("server.port", "9137");
      dbServer = new org.hsqldb.Server();
      try {
          dbServer.setProperties(props);
      } catch (Exception e) {
          return;
      }
      dbServer.start();
  }
  </code></pre>
  
  <p>However, when I then try and start the database server I get the following error stacktrace: </p>
  
  <pre><code>java.sql.SQLTransientConnectionException: java.net.ConnectException: Connection refused: connect2015-04-27 11:42:02,306 INFO
   [Thread-2] server.DatabaseWorker (DatabaseWorker.java:20) - Database server is Running
  
          at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
          at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
          at org.hsqldb.jdbc.JDBCConnection.&lt;init&gt;(Unknown Source)
          at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
          at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
          at java.sql.DriverManager.getConnection(DriverManager.java:664)
          at java.sql.DriverManager.getConnection(DriverManager.java:247)
          at rideabike.server.DatabaseManager.getDBConn(DatabaseManager.java:37)
          at rideabike.server.DatabaseWorker.run(DatabaseWorker.java:18)
  Caused by: org.hsqldb.HsqlException: java.net.ConnectException: Connection refused: connect
          at org.hsqldb.ClientConnection.openConnection(Unknown Source)
          at org.hsqldb.ClientConnection.initConnection(Unknown Source)
          at org.hsqldb.ClientConnection.&lt;init&gt;(Unknown Source)
          ... 7 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 org.hsqldb.server.HsqlSocketFactory.createSocket(Unknown Source)
          ... 10 more
  </code></pre>
  
  <p>Is there anything further I need to do to try and change the port that the HSQLDB server uses? Any help is greatly appreciated, thanks.</p>