简体   繁体   English

带有休眠和超时的tomcat数据源,等待空闲对象异常

[英]tomcat datasource with hibernate and Timeout waiting for idle object exception

I am using Tomcat Data-source with hibernate 我在休眠状态下使用Tomcat数据源

<Resource 
auth="Container" 
driverClassName="com.mysql.jdbc.Driver" 
maxActive="8" maxIdle="8" maxWait="10000"
username="*****"  
name="jdbc/sakila" password="*****"
type="javax.sql.DataSource" 
url="jdbc:mysql://localhost/sakila"/>

and in hibernate 并处于休眠状态

<propertyname="hibernate.connection.datasource">java:comp/env/jdbc/sakila</property>

after implementing I am facing the following exception 实施后,我面临以下异常

java.util.NoSuchElementException: Timeout waiting for idle object

this exception occur at night , when I am sleeping :) and as I go office at morning I found this exception. 这个异常发生在晚上,当我睡​​觉时:),而当我早上上班时,我发现了这个异常。 I think this is connection pooling exception that tomcat provide? 我认为这是tomcat提供的连接池异常吗?

please update me ! 请更新我!

This it is suitable to use tomcat Data-source with hibernate? 这适合将tomcat数据源与hibernate一起使用吗? or we should use C3P0 third party connection polling?; 还是应该使用C3P0第三方连接轮询?

currently, looking solution for tomcate data source 目前,正在寻找解决方案以合并数据源

The number of the connections in the pool grows automatically until it reaches maxActive. 池中的连接数会自动增长,直到达到maxActive为止。

Per Tomcat documentation, maxActive is: 根据Tomcat文档,maxActive为:

The maximum number of active connections that can be allocated from this pool at the same time. 可以同时从该池分配的最大活动连接数。 The default value is 100 默认值为100

You severly restricted the maximum number of the simultaneous database connections to 8. 您已将最大同时数据库连接数限制为8个。

I would suggest to increase this number to at least 50. Then start monitoring the number of the connections in the pool. 我建议将该数目增加到至少50。然后开始监视池中的连接数目。 If the number of the connections steadily grows, whitout the growth of the usage of your web application, you might have a connection leak. 如果连接数量稳步增长,而Web应用程序使用率却没有增长,则可能是连接泄漏。 If you confirm that, you would have to investigate that leak. 如果确认,则必须调查该泄漏。

Unlike the "olden days", if you connect to the datavase via Hibernate and manage transactions with, say, Spring, connection leaks are quite rare. 与“过去”不同,如果您通过Hibernate连接到数据花瓶并使用Spring管理事务,则连接泄漏非常少见。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.apache.tomcat.dbcp.dbcp.SQLNestedException:无法获得连接,池错误超时等待空闲对象 - org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object apache commons dbcp connection pool error:使用Spring Transactions在Spring + Hibernate应用程序中等待空闲对象超时 - apache commons dbcp connection pool error: Timeout waiting for idle object in a Spring + Hibernate app using Spring Transactions 等待空闲对象Apache连接池超时 - Timeout waiting for idle object Apache connection Pool Tomcat数据源配置连接超时和最大活动到空闲连接比率 - Tomcat Datasource configuration Connection timeout and Max Active to Idle connection ratio 池错误超时等待空闲对象(Java JDBC) - Pool error Timeout waiting for idle object (Java JDBC) 在Hibernate 5,Tomcat 8中配置数据源 - Datasource configuring in Hibernate 5, Tomcat 8 需要有关[java.util.NoSuchElementException:等待空闲对象的超时]的说明 - Need explanation about [java.util.NoSuchElementException: Timeout waiting for idle object] 为什么出现此错误-无法获得连接,池错误等待空闲对象的超时 - Why this error - Cannot get a connection, pool error Timeout waiting for idle object java.sql.SQLException: 无法获得连接,池错误超时等待空闲对象。 如何恢复连接 - java.sql.SQLException: Cannot get a connection, pool error Timeout waiting for idle object . How to recover the connection 得到以下错误“无法建立连接,池错误超时等待空闲对象” - Getting the following error “Cannot get a connection, pool error Timeout waiting for idle object”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM