Spring MVC-org.hibernate.exception.GenericJDBCException:无法获取JDBC连接

时间:2020-07-16 19:31:19

标签: java mysql spring hibernate spring-jdbc

尽管应用程序正在使用中,但MySQL出现以下错误-

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112) org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112)  at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112)  at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112)  at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112)  at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:109)

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112)  at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:136)

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112)  at org.hibernate.internal.SessionImpl.connection(SessionImpl.java:523)

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112)  at com.mycompany.myproject.infrastructure.db.hibernate.dao.impl.HDexSessionDAOImpl.getMetadataColumnLength(HDexSessionDAOImpl.java:1383)

     2020-07-16 14:17:34,229 ERROR [stderr] (default task-112)  at com.mycompany.myproject.infrastructure.db.hibernate.dao.impl.HDexSessionDAOImpl.updateDexSession(HDexSessionDAOImpl.java:127)

MySQL服务器设置- mysql>显示全局变量,如“ interactive_timeout”; + --------------------- + ------- + |变量名|价值| + --------------------- + ------- + | Interactive_timeout | 2880 | + --------------------- + ------- + 设置1行(0.00秒)

        mysql>  SHOW GLOBAL VARIABLES LIKE "wait_timeout";
        +---------------+-------+
        | Variable_name | Value |
        +---------------+-------+
        | wait_timeout  | 28800 |
        +---------------+-------+
        1 row in set (0.00 sec)

        mysql>  SHOW GLOBAL VARIABLES LIKE "connect_timeout";
        +-----------------+-------+
        | Variable_name   | Value |
        +-----------------+-------+
        | connect_timeout | 10    |
        +-----------------+-------+
        1 row in set (0.00 sec)

我的hibernate.properties文件设置-

         hibernate.c3p0.min_size=5
         hibernate.c3p0.max_size=20
         hibernate.c3p0.acquire_increment=1
         hibernate.c3p0.timeout=300
         hibernate.c3p0.max_statements=150

我还尝试了其他问题的推荐解决方案。所以这不是重复的。

感谢您的帮助。

谢谢

0 个答案:

没有答案