首页 \ 问答 \ 如何更改HSQLDB服务器侦听的端口(How to change port that HSQLDB server listens on)

如何更改HSQLDB服务器侦听的端口(How to change port that HSQLDB server listens on)

我以编程方式启动HSQLDB服务器,但是当我尝试将HSQLDB服务器与我正在开发的Web应用程序一起运行时,我遇到了端口冲突。 我在webapp端遇到以下错误

java.util.concurrent.ExecutionException: java.net.BindException: Address already in use: JVM_Bind

我在数据库服务器端遇到此错误:

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)   

我不知道为什么会出现这个错误。 但是,当我查看webapp和HSQLDB使用的端口时,我发现它们都使用9001,因此我认为问题与冲突的端口有关,而与HSQLDB版本无关。 但是,我不确定。

我知道HSQLDB使用的默认端口号是9001,我试图通过将用于9137的端口设置为以下代码来更改它。

    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();
}

但是,当我尝试启动数据库服务器时,我得到以下错误堆栈跟踪:

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.<init>(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.<init>(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.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)
        at org.hsqldb.server.HsqlSocketFactory.createSocket(Unknown Source)
        ... 10 more

我还需要做些什么来尝试更改HSQLDB服务器使用的端口吗? 非常感谢任何帮助,谢谢。


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

java.util.concurrent.ExecutionException: java.net.BindException: Address already in use: JVM_Bind

& I get this error on the database server side:

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)   

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.

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.

    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();
}

However, when I then try and start the database server I get the following error stacktrace:

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.<init>(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.<init>(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.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)
        at org.hsqldb.server.HsqlSocketFactory.createSocket(Unknown Source)
        ... 10 more

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.


原文:https://stackoverflow.com/questions/29894028
更新时间:2023-05-13 17:05

相关问答

更多

相关文章

更多

最新问答

更多
  • 如何检索Ember.js模型的所有属性(How to retrieve all properties of an Ember.js model)
  • maven中snapshot快照库和release发布库的区别和作用
  • arraylist中的搜索元素(Search element in arraylist)
  • 从mysli_fetch_array中获取选定的值并输出(Get selected value from mysli_fetch_array and output)
  • Windows Phone上的可用共享扩展(Available Share Extensions on Windows Phone)
  • 如何在命令提示符下将日期设置为文件名(How to set file name as date in command prompt)
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • 从iframe访问父页面的id元素(accessing id element of parent page from iframe)
  • linux的常用命令干什么用的
  • Feign Client + Eureka POST请求正文(Feign Client + Eureka POST request body)
  • 怎么删除禁用RHEL/CentOS 7上不需要的服务
  • 为什么Gradle运行测试两次?(Why does Gradle run tests twice?)
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在android中的活动之间切换?(Switching between activities in android?)
  • Perforce:如何从Depot到Workspace丢失文件?(Perforce: how to get missing file from Depot to Workspace?)
  • Webform页面避免运行服务器(Webform page avoiding runat server)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 内存布局破解(memory layout hack)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • 我们可以有一个调度程序,你可以异步添加东西,但会同步按顺序执行吗?(Can we have a dispatcher that you can add things todo asynchronously but will be executed in that order synchronously?)
  • “FROM a,b”和“FROM a FULL OUTER JOIN b”之间有什么区别?(What is the difference between “FROM a, b” and “FROM a FULL OUTER JOIN b”?)
  • Java中的不可变类(Immutable class in Java)
  • bat批处理文件结果导出到txt
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • 德州新起点计算机培训学校主要课程有什么?
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • “latin1_german1_ci”整理来自哪里?(Where is “latin1_german1_ci” collation coming from?)