老师,这是什么原因呀?

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

皮皮猪6688

2017-10-27 13:37

//img1.mukewang.com/59f2c73e00019adf12150397.jpgException in thread "main" java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)

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

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

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

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

at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1710)

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

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2191)

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

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

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

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

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

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

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

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

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at jdbc_imooc.CKXa.main(CKXa.java:19)


写回答 关注

2回答

  • Queen丶Star
    2017-11-15 22:35:38

    仔细检查你的URL地址

    皮皮猪668...

    可以了 ,蟹蟹^_^

    2017-11-16 09:29:23

    共 1 条回复 >

  • Leroyy
    2017-10-27 15:44:03

    数据库的账号和密码可能不对

    皮皮猪668...

    我登数据库就是用的这个账号密码,但是到这个就报错了

    2017-10-27 16:16:01

    共 1 条回复 >

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

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

99327 学习 · 856 问题

查看课程

相似问题