0

I connected a MySQL database for a project (java web application) in netbeans. I created MySQL server with correct login details as root and created a database. I connected my database to the project, but when I am running the application it was showing error in the browser as:

type Exception report

message Internal Server Error

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: java.sql.SQLException: Access denied for user 'User'@'localhost' (using password: YES)

root cause

java.sql.SQLException: Access denied for user 'User'@'localhost' (using password: YES)

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

Entry in the log file is:

java.sql.SQLException: Access denied for user 'User'@'localhost' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:925)
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1704)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1250)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2465)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2498)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2283)
    at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:822)
    at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:404)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at org.apache.jsp.Login_jsp.cn(Login_jsp.java:114)
    at org.apache.jsp.Login_jsp._jspService(Login_jsp.java:589)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411) 

I am tired in few ways as mentioned in some other forms but not use.

8
  • You didn't have user with name User exists and if it exists then User account is not password protected. First try connecting DB with UN and PW you are using in your code. Commented Mar 8, 2016 at 5:50
  • @Naman . User is created surely because when I see in mysql list of users it is showing that name also. Commented Mar 8, 2016 at 6:19
  • Have you tried login in mysql using that UN(User) & PW(your PW)? Commented Mar 8, 2016 at 6:27
  • @Naman yes, but i is showing error as ERROR 1045 (28000): Access denied for user 'User'@'localhost' (using password: YES) Commented Mar 8, 2016 at 6:30
  • You must have entering wrong password for user. Commented Mar 8, 2016 at 7:34

2 Answers 2

0

You didn't create the user 'bkUser'@'localhost' correctly.

Sign up to request clarification or add additional context in comments.

2 Comments

i created correctly by using the following sql statment: <br/><pre> GRANT ALL PRIVILEGES ON dbname.* TO 'User'@'%' IDENTIFIED BY 'Pass' WITH GRANT OPTION; </pre>
MySQL doesn't agree with you. You got at least the password wrong.
0

I found solution, When I was using sql statement for grant privileges i used

'user@%'
because of that it was not working. Correct sql statement was:
GRANT ALL PRIVILEGES ON dbname.* TO 'User'@'localhost' IDENTIFIED BY 'Pass' WITH GRANT OPTION; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.