Reputation: 59385
I'm trying run a simple Java/MySQL web app tutorial in NetBeans.
I am able to connect to my database from a standard Java program in NetBeans, and Tomcat is working. But when I try to connect to the database from a JSP, I get the following error:
javax.servlet.ServletException: javax.servlet.jsp.JspException:
Unable to get connection, DataSource invalid:
"org.apache.tomcat.dbcp.dbcp.SQLNestedException:
Cannot create PoolableConnectionFactory
(Access denied for user 'root'@'localhost' (using password: YES))"
I know I have the correct password set, since other (Java SE) programs can connect to the database. Can anyone point me where to look?
I'm using NetBeans 6.7, MySQL 5.1, and Tomcat 6.0.18 in Windows Vista.
Upvotes: 1
Views: 4445
Reputation: 2256
The username root
can be used to login from the same machine only and not remotely. Try creating another user ID with all permissions.
have a look at Adding user accounts. In that page you will see two queries
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
Here the 2nd monty@%
can be used to login remotely whereas the first is restricted to local login.
Upvotes: 3