0

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

xmux
  • 708
  • 2
  • 12
  • 28

3 Answers3

1

The stack trace indicates that the MySQL DB is not running on port 1527

See https://netbeans.org/kb/docs/ide/mysql.html

Rob Kielty
  • 7,958
  • 8
  • 39
  • 51
  • yes, definetly i finished first this tutorial, and everything was ok. i wrote the port for MySQL 3306 – xmux Oct 01 '13 at 21:49
  • ah I see. so like you said in the question u need to figure out why nb is referencing what looks like a Derby conn string. – Rob Kielty Oct 01 '13 at 22:21
  • might be useful to name your OS so we can provide OS specific troubleshooting and health checking tips. – Rob Kielty Oct 01 '13 at 22:23
  • i found the solution: I tried it with Glassfish 3 and Java EE 5 then it just worked! I think there is a problem with Glassfish 4 and Java EE 7, it is probably because of the Jstl, but i am not so sure. – xmux Oct 01 '13 at 22:31
  • Fair play, well done! You should accept your own answer so that future visitors can quickly see that it was what worked for you. – Rob Kielty Oct 02 '13 at 08:28
  • Thanks! Isn't it Accepting and Voting for yourself is not allowed? – xmux Oct 02 '13 at 11:22
0

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

xmux
  • 708
  • 2
  • 12
  • 28
  • You need to follow all the directions in the NetBeans Tutorial you linked to above. It links to a tutorial on connecting to MySql (https://netbeans.org/kb/docs/ide/mysql.html) and the instructions specifically detail how to use an existing JDBC connection to create the JDBC resource used in the application. – Ian Evans Oct 09 '13 at 17:21
0

I had a similar problem and I solved it using a different approach. I changed the settings in the glassfish-web.xml file found in IFPWAFCAD/WebPages/WEB-INF folder. The following settings worked for me for this particular tutorial https://netbeans.org/kb/docs/web/mysql-webapp.html:


Resource Reference name: jdbc/IFPWAFCAD
JNDI Name: jdbc/IFPWAFCAD
Principal Name: root
Principal Password: nbuser


These settings will work for this particular tutorial - I used glassfish 4 - and Java EE 5. No need to install glassfish 3

Alicja
  • 1
  • 1