美文网首页
六、mysql连接异常

六、mysql连接异常

作者: lifeline张 | 来源:发表于2019-04-02 00:10 被阅读0次

今天遇到的bug如下:

org.hibernate.tool.schema.spi.SchemaManagementException: Unable to open JDBC connection for schema management target
    at org.hibernate.tool.schema.internal.TargetDatabaseImpl.prepare(TargetDatabaseImpl.java:42)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:57)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:133)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:101)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:470)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
    at com.itheima.hibernate.demo1.HibernateDemo1.demo1(HibernateDemo1.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:689)
    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
    at org.hibernate.c3p0.internal.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:73)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
    at org.hibernate.tool.schema.internal.TargetDatabaseImpl.prepare(TargetDatabaseImpl.java:38)
    ... 31 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
    at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1418)
    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:606)
    at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:526)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:755)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:682)
    ... 35 more

问题的原因在于我为了装逼安装的是最新版本的mysql:8.0.15


image.png

但是我的mysql连接jar包还是老版本的,对这个不支持,所以就会报这个错误,解决办法是下载支持这个mysql版本的jar包,替换掉老的jar包,同时还要修改mysql的连接配置:

<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate_day01?useSSL=false&amp;serverTimezone=UTC</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">41312019zhang</property>

这样才解决掉。
还好老子嗅觉敏锐,在一个人的博客中注意到这个问题。
新版真是蛋疼,卡了老子一个多小时,现在十二点多了,草!

相关文章

  • 六、mysql连接异常

    今天遇到的bug如下: 问题的原因在于我为了装逼安装的是最新版本的mysql:8.0.15 但是我的mysql连接...

  • mysql连接异常

    错误: Host is blocked because of many connection errors; un...

  • 2017-03-05

    ~关于mac下连接mysql和mysql workbench连接mysql的异常 有人可能会跟我一样在安装mysq...

  • Mysql产生No operations allowed aft

    Mysql产生No operations allowed after connection closed连接异常的解决

  • Navicat ,SQLyog连接MySQL8 异常 Authe

    问题:Navicat ,SQLyog连接MySQL8 异常2059-Authentication plugin '...

  • nodejs连接mysql异常

    在用nodejs开发后台,进行连接mysql时报错:ER_NOT_SUPPORTED_AUTH_MODE: Cli...

  • C3P0连接池内连接有效性配置

    如果MySQL连接池内连接失效,继续读写会出现异常: 解决方案:增加配置: 官网配置: testConnectio...

  • MySQL:设置时区

    1. 背景 在开发过程中,设置 IDEA 连接数据mysql数据库连接时遇到异常“Server returns i...

  • 【django】多进程连接Mysql异常

    场景: 我遇到的情况是Django下多进程连接数据库异常,设置为每次连数据库前先断开之前的连接就可以了。 报错: ...

  • mysql 自学第一天

    mysql数据库【大概8点20分发】 连接退出 由于mysql对格式要求异常严格,dos操作又不便捷,所以请常用记...

网友评论

      本文标题:六、mysql连接异常

      本文链接:https://www.haomeiwen.com/subject/mnpibqtx.html