连接mysql错误,Druid-ConnectionPool-Create-1641320886-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

连接mysql错误,Druid-ConnectionPool-Create-1641320886

自由的心_ 2018-04-18 17:14:14 20373

16:52:01.163 [Druid-ConnectionPool-Create-1641320886] ERROR com.alibaba.druid.pool.DruidDataSource - create connection error, url: jdbc:mysql://localhost:3306/jf?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.

at sun.reflect.GeneratedConstructorAccessor26.newInstance(Unknown Source) ~[?:?]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_144]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_144]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:408) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.Util.getInstance(Util.java:383) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1023) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2576) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2309) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46) ~[mysql-connector-java-5.1.32.jar:?]
at sun.reflect.GeneratedConstructorAccessor23.newInstance(Unknown Source) ~[?:?]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_144]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_144]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:408) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:419) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344) ~[mysql-connector-java-5.1.32.jar:?]
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1375) ~[druid-1.0.11.jar:1.0.11]
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1431) ~[druid-1.0.11.jar:1.0.11]
at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1857) [druid-1.0.11.jar:1.0.11]

Caused by: java.lang.NullPointerException

at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:3299) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1967) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1893) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1287) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2494) ~[mysql-connector-java-5.1.32.jar:?]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2527) ~[mysql-connector-java-5.1.32.jar:?]
... 12 more
关系型数据库 MySQL Java 数据库连接
分享到
取消 提交回答
全部回答(3)
  • chanze
    2019-07-17 22:06:05

    题主好,我也犯了一样的错误,请问你是怎么解决的?url username password都没有错,代码在其他人的电脑可以跑,就只有在我的电脑跑不了

    0 0
  • w0807m
    2019-07-17 22:06:05

    从报错上看,是连接本地mysql报错,也就是连接不上本地mysql导致的。先用mysql -u xx -p 登录一下,看是否本地的mysql能否登录。然后再确认,端口3306是否正确,以及端口是否打开。可以先关闭防火墙试试。

    0 0
  • dongshan8
    2019-07-17 22:06:05

    题主您好,

    看起来,好象是连接本地的mysql数据库出错。

    请问您的tomcat项目和数据库是在同一个服务器吗?

    同一台服务器上的mysql是否有启动呢?

    0 0
添加回答
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题
推荐课程