0
votes

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.

2
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. - Naman
@Naman . User is created surely because when I see in mysql list of users it is showing that name also. - krocks
Have you tried login in mysql using that UN(User) & PW(your PW)? - Naman
@Naman yes, but i is showing error as ERROR 1045 (28000): Access denied for user 'User'@'localhost' (using password: YES) - krocks
You must have entering wrong password for user. - Naman

2 Answers

0
votes

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

0
votes

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

'user@%'
GRANT ALL PRIVILEGES ON dbname.* TO 'User'@'localhost' IDENTIFIED BY 'Pass' WITH GRANT OPTION;