游泳池中使用的所有连接都很困难,并建立了新连接

问题描述:

我们使用c3p0Hibernate一起使用。但是hibernate并没有重用池中的连接。当我看到mysql-workbench用于客户端连接时,我可以看到其中大部分都处于“睡眠”状态。随着时间的推移,游泳池按照我指定的增量持续增长,直到我最终耗尽。游泳池中使用的所有连接都很困难,并建立了新连接

下面是从数据配置片断:

persistenceMap.put(
    "connection.provider_class", "org.hibernate.connection.C3P0ConnectionProvider" 
); 
persistenceMap.put("hibernate.c3p0.min_size", "1"); 
persistenceMap.put("hibernate.c3p0.max_size", "5"); 
persistenceMap.put("hibernate.c3p0.timeout", "5"); 
persistenceMap.put("hibernate.c3p0.max_statements", "20"); 
persistenceMap.put("hibernate.c3p0.acquire_increment", "1"); 
persistenceMap.put("hibernate.c3p0.maxIdleTimeExcessConnections", "3"); 

MYSQL - 工作台 - >客户端连接:

enter image description here

请帮助/咨询。

以下解决方案似乎是为我工作

连接池罐已被更新。

  • c3p0-0.9.2.1
  • hibernate-c3p0-5.1.0.Final
  • mchange公地的Java-0.2.3.4

持久性一直改变如下。 残留性

persistenceMap.put("javax.persistence.jdbc.url","jdbc:mysql://localhost:3306/test_db"); 
persistenceMap.put("javax.persistence.jdbc.user", "root"); 
persistenceMap.put("javax.persistence.jdbc.password", "root"); 
persistenceMap.put("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver"); 
persistenceMap.put("hibernate.show_sql", "true"); 
persistenceMap.put("hibernate.format_sql", "true"); 
persistenceMap.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); 
persistenceMap.put("hibernate.hbm2ddl.auto", "validate"); 

persistenceMap.put("hibernate.connection.provider_class", "org.hibernate.connection.C3P0ConnectionProvider"); 
persistenceMap.put("hibernate.c3p0.min_size", "1"); 
persistenceMap.put("hibernate.c3p0.max_size", "20"); 
persistenceMap.put("hibernate.c3p0.timeout", "10"); 
persistenceMap.put("hibernate.c3p0.max_statements", "50"); 

仅供参考... 我使用 操作系统:Ubuntu的 Java版本:8 Hibernate的版本:5.1.0