java.sql.sqlnontransientconnectionexception: java.net.connectException : error connecting to server localhost on port

你。 提交于 2019-12-20 06:48:47

问题


I've being working on a java project using Derbyclient (database locally hosted). I'm done with everything except that when I'm trying the desktop app while I'm not manually connected to the database (from Netbeans), the error in the title pops up and I can't seem to solve it. Thank you for taking the time to read this and help me.


回答1:


Derby can be run in two modes embedded or server-based. Server-based allows multiple programs to access the same database. Embedded allows your application to run without a server. Your url selects server-based. The connection refused error indicates that the server is not running. Since the server was started within Netbeans it is shutdown when Netbeans is not running.

The options are:

  1. Switch to embedded.
  2. Start the server with a command outside Netbeans.
  3. Just keep Netbeans running.

To switch to embedded see Apache's documentation for deployment options: Eliminate the "//localhost:1527" from the url. also see the tutorial "Run SQL using the embedded driver" at https://builds.apache.org/job/Derby-docs/lastSuccessfulBuild/artifact/trunk/out/getstart/index.html

To start the server in a seperate command window see the syntax for derbyrun.jar: https://builds.apache.org/job/Derby-docs/lastSuccessfulBuild/artifact/trunk/out/getstart/rgsderbyrunjarsyntax.html



来源:https://stackoverflow.com/questions/32018331/java-sql-sqlnontransientconnectionexception-java-net-connectexception-error-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!