java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) select * from usertable where UserName='汪汪队'and Password='1012' Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at DBConn.DataBaseManager.getResult(DataBaseManager.java:31) at Forms.UserLogin.actionPerformed(UserLogin.java:76) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)这个报错怎么解决
时间: 2024-04-21 19:25:39 浏览: 77
这个报错是由于使用指定的用户名和密码无法连接到本地 MySQL 数据库引起的,可能是因为用户名或密码不正确或者没有给这个用户授权访问该数据库的权限。解决这个问题的方法如下:
1. 确认用户名和密码是否正确,并且是否有权限访问该数据库。
2. 确认 MySQL 服务是否已经启动,如果没有,请启动它。
3. 如果你使用的是 localhost 作为主机名,请尝试使用 127.0.0.1 来替换它,因为在某些情况下,localhost 会出现一些问题。
4. 如果仍然无法解决问题,请检查防火墙设置是否阻止了 MySQL 数据库的访问,如果是,请允许 MySQL 数据库的访问。
5. 如果以上方法都无法解决问题,请检查你的代码是否正确,你可以尝试使用其他的 MySQL 客户端来连接到数据库,看是否能够成功连接。
相关问题
java.sql.sQLException: Access denied for user 'root' @ localhost' (using password: YES)
java.sql.sQLException: Access denied for user 'root' @ localhost' (using password: YES)异常是由于访问数据库时密码不正确导致的。您检查您的密码是否输入正确,并且确保您有适当的权限来访问数据库。如果您确定密码正确且权限正确,那么可能是由于其他配置或网络问题导致无法访问数据库。
java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
java.lang.RuntimeException: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 这个错误是由于在连接数据库时使用的用户名和密码不导致的。用户名应为'root',密码应正确输入。请确保用户名和密码正确并重新连接数据库。
阅读全文