跟着老师打一遍之后显示的是这个 怎么回事

来源:2-2 JDBC实战---打通数据库

pddd

2018-04-18 11:59

Exception in thread "main" java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)

at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4004)

at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1284)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2312)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)

at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774)

at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)

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:423)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)

at java.sql.DriverManager.getConnection(DriverManager.java:664)

at java.sql.DriverManager.getConnection(DriverManager.java:247)

at jdbc_imooc.db.DBUtil.main(DBUtil.java:15)


写回答 关注

2回答

  • 高数CC
    2018-05-30 14:52:38

    密码错误了,如果是首次安装的数据库,是没有密码的

  • 灬乱世烟花丶盛世繁华灬
    2018-04-18 14:13:35

    你这个应该是数据库路径连接成功了,然后电脑上安装的mysql的数据库的用户名和密码应该不对。你认真看一下

JDBC之 “ 对岸的女孩看过来”

一起领略JDBC的奥秘,为进一步学习集成框架打下良好的基础

99327 学习 · 856 问题

查看课程

相似问题