Netbeans 7.3.1无法建立与jdbc:derby的连接

时间:2014-10-29 13:20:25

标签: java netbeans derby

最近,我正在使用Java EE处理这个小项目,我需要使用derby数据库,但每次我去服务 - >数据库并尝试连接到我的jdbc:derby时出现此错误:

无法连接。无法使用org.apache.derby.jdbc.ClientDriver建立与jdbc:derby:// localhost:1527 //示例的连接(java.netConnectException:在端口1527上连接到服务器localhost时出错,并显示消息Connection refused:connect。)。< / p>

和这个例外:

Wed Oct 29 15:05:26 EET 2014 : access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
    at java.security.AccessController.checkPermission(AccessController.java:884)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkListen(SecurityManager.java:1131)
    at java.net.ServerSocket.bind(ServerSocket.java:374)
    at java.net.ServerSocket.<init>(ServerSocket.java:237)
    at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
    at org.apache.derby.impl.drda.NetworkServerControlImpl.createServerSocket(Unknown Source)
    at org.apache.derby.impl.drda.NetworkServerControlImpl.access$000(Unknown Source)
    at org.apache.derby.impl.drda.NetworkServerControlImpl$1.run(Unknown Source)
    at java.security.AccessControWed Oct 29 15:05:26 EET 2014 : access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")
    at java.security.AccessContrller.doPrivileged(Native Method)
    at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(Unknown Source)
    at org.apache.derby.impl.drda.NetworkServerControlImpl.executeWork(Unknown Source)
    at org.apache.derby.drda.NetworkServerControl.maiolContext.checkPermission(AccessControlContext.java:457)
    at java.security.AccessController.checkPermission(AccessController.java:884)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkListen(SecurityManager.java:1131)
    at java.net.ServerSocket.bind(ServerSocket.java:374)
    at java.net.ServerSocket.<init>(ServerSocket.java:237)
    at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
    at org.apache.derby.impl.drda.NetworkServerControlImpl.createServerSocket(Unknown Source)
    at org.apache.derby.impl.drda.NetworkServerControlImpl.access$000(Unknown Source)
    at org.apache.derby.impl.drda.NetworkServerControlImpl$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(Unknown Source)
    at org.apache.derby.impl.drda.NetworkServerControlImpl.executeWork(Unknown Source)
    at org.apache.derby.drda.NetworkServerControl.main(Unknown Source)
n(Unknown Source)

任何想法如何解决?

2 个答案:

答案 0 :(得分:0)

您是否已经尝试过这里的提示http://wiki.netbeans.org/JavaDB_grant_permissions

JDK 7u51带来了一些安全性改进,这些改进导致在此Java版本上启动Java DB时出现问题。

当您尝试从NetBeans启动数据库时,您可能会收到异常:

 java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")

开始使用script / db / bin / startNetworkServer

时会遇到同样的异常

因为没有合适的方法在NetBeans端修复它,所以应该在Java DB的侧面修复它。

有几种方法可以解决这个问题。我只会提到最简单的方法。您必须从命令行手动启动DB。

使用-noSecurityManager参数启动Java DB。

  <JDK 7u51 location>/db/bin/startNetworkServer -noSecurityManager

答案 1 :(得分:0)

您需要在项目属性中添加起始页面。 打开项目属性。然后选择tab run。然后将项目开始页面添加到相对URL文本框。我的是“/index.jsp”。

很抱歉,如果我的英语语法有误。