2014-02-11 208 views
1

我試圖連接到netbeans上的derby數據庫,但每次都會出現此錯誤。我已經做了一些研究,看到人們通過編輯策略文件解決了這個問題,但這並沒有幫助我。任何幫助,將不勝感激。Java數據庫連接無法連接到Derby數據庫Netbeans 7.4

Tue Feb 11 11:49:08 EST 2014 : Security manager installed using the Basic server security policy. 
Tue Feb 11 11:49:09 EST 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:372) 
    at java.security.AccessController.checkPermission(AccessController.java:559) 
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) 
    at java.lang.SecurityManager.checkListen(SecurityManager.java:1134) 
    at java.net.ServerSocket.bind(ServerSocket.java:375) 
    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) 
+0

好吧,這個錯誤不是來自嘗試連接到您的數據庫,它來自嘗試啓動網絡服務器。您是否按照https://db.apache.org/derby/docs/10.10/adminguide/tadminnetservbasic.html上的說明進行操作 –

回答

2

我與netbeans 7.4有同樣的問題。試試這個:

  1. 找出究竟在何處Java主是通過執行將NetBeans 7.4指令:

    System.out.println(System.getProperty(「java.home」));

    在我的情況是:

    C:\Program Files\Java\jdk1.7.0_51\jre

    它真的很重要找到正確的配置文件夾。

  2. 打開文件

{your path}\lib\security\java.policy

應該是這樣的:

C:\Program Files\Java\jdk1.7.0_51\jre\lib\security\java.policy

您可能需要管理員權限。

3.添加此行到批塊:

permission java.net.SocketPermission "localhost:1527", "listen,resolve"; 


保存文件並嘗試連接到您的數據庫。

希望這會有所幫助。