Search code examples
javamysqlnetbeansglassfishjava-ee-7

Unable to get connection, DataSource invalid - Netbeans, MySQL


I'm following the tutorial of Netbeans site:

https://netbeans.org/kb/docs/web/mysql-webapp.html

everything was working fine until this step: Implementing JSTL code STEP 4 where the list should be displayed I get the following error:

javax.servlet.ServletException: javax.servlet.jsp.JspException: 
Unable to get connection, DataSource invalid: "java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused."
root cause

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException :
         Error connecting to server localhost on port 1527 with message Connection refused."

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.

I suppose netbeans still tries to connect to the Derby DB. How can i change it to MySQL DB? I am using Java EE7, MySQL, Netbeans, Glassfish 4


Solution

  • Use GlassFish Server Open Source Edition 3.x and Java EE Version 5 or 6 Then it works.