我试图连接到netbeans上的derby数据库,但每次都会出现此错误。我做了一些研究,看到人们通过编辑策略文件解决了这个问题,但这对我没有帮助。任何帮助将不胜感激。
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 :(得分:3)
我遇到了与netbeans 7.4相同的问题。试试这个:
通过从Netbeans 7.4执行此指令找出java home的确切位置:
System.out.println(System.getProperty(“java.home”));
就我而言:
C:\Program Files\Java\jdk1.7.0_51\jre
找到合适的配置文件夹非常重要。
打开文件
{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";
保存文件并尝试连接到您的数据库。
希望这有帮助。