Search code examples
javajava-ee-6javadbnetbeans-8.1

Installing Java EE 6 Tutorial examples: JavaDB error (java.sql.SqlNonTransientConnectionException: recv failed)


I'm trying to install and run Java EE 6 Tutorial examples. In this particular case, Duke's Forest Case Study Example. No problem with first install step "To Create the JDBC Realm and Populate the Database", apparently the JavaDB is created and populated. But in second step I'm getting the following error trying to connect to JavaDB: "An error occurred while creating the database: java.sql.SqlNonTransientConnectionException: A communications error has been detected: Software caused connection abort: recv failed.."

The strange thing is that although connecting JavaDB seems not to work, the db creation using "ant" with the tutorial scripts seems to work. And furthermore, starting the JavaDB Server seems to work as well, showing a message stating it is ready and listening on port 1527.

Similar problem asked in Getting a java.sql.SqlNonTransientConnectionException.

I'm running Windows XP, NetBeans 8.1, JDK 1.7.0_60.


Solution

  • Finally, I found the problem. It's a little tricky, although now it seems obvious. I use two different network configurations for browsing, one using a Socks v5 proxy (in Chrome) and one without a proxy (in Firefox). The one in Chrome is the Windows XP default and now I know that Netbeans use this.

    When I executed the 'ant' script (step 1 in the tutorial), I use a command line window, which it seems not to use the default Windows network configuration. So I got no errors. But, when I tried to connect from Netbeans, the error was shown.

    Now, I've eliminated the proxy in the default network configuration, I've restarted Netbeans and it works!

    NOTE: After that, I found the “Proxy Settings” in the NetBeans Options dialog. By default, NetBeans set “Use System Proxy Settings”. So, I thought that changing to “No proxy”, everything would go well, but no. The JavaDB connection worked, but when I tried to start Glassfish, found that it use the proxy configuration for network connection. I have also found a check in the NetBeans Glassfish server configuration dialog (Java Tab) named “Use IDE’s proxy settings” that seemed to be related to this question, but after several testing, I found that didn’t work.