Unable to start derby database from Netbeans 7.4

Superman9999 picture Superman9999 · Jan 16, 2014 · Viewed 73.6k times · Source

I downloaded Netbeans 7.4 and Java 7 Update 51. I get the below error when I try to start Java DB or derby connection from Netbeans. This is on a windows 8 PC. I downloaded the version for windows xp 32 bit at work. It works fine. I am not sure what is missing.

Thu Jan 16 00:48:23 EST 2014 : Security manager installed using the Basic server security policy.
Thu Jan 16 00:48:24 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)

connection properties java db properties

Answer

user2060065 picture user2060065 · Jan 20, 2014

This is what I did:

  1. Find out exactly where the java home is by executing this instruction from NetBeans 7.4 :

    System.out.println(System.getProperty("java.home"));

    This is the output for my case:

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

    which is quite important for me, I was modifying another java.policy and took no effect and wasted me a couple of hours.

  2. For reason of java.policy is an unix style file and read-only, I opened and edited it with notepad++ and executed as administrator (under the same java home):

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

    Add only these lines into the file after the first grant:

    grant {
        permission java.net.SocketPermission "localhost:1527", "listen";
    };
  3. Save the file, which is a little tricky for reason of the permission. But if you run notepad++ or any other edit program as administrator, you can solve the problem.

    Then try to connect the database from NetBeans, it works for me.

Good luck.