c3p0

hibernate c3p0 broken pipe

余生颓废 提交于 2019-12-04 20:30:28
I'm using hibernate 3 with c3p0 for a program which constantly extracts data from some source and writes it to a database. Now the problem is, that the database might become unavailable for some reasons (in the simplest case: i simply shut it down). If anything is about to be written to the database there should not be any exception - the query should wait for all eternity until the database becomes available again. If I'm not mistaken this is one of the things the connection pool could do for me: if there is a problem with the db, just retry to connect - in the worst case for infinity. But

How to re-deploy a hibernate-c3p0 project on tomcat 7 without getting strange c3p0 errors

邮差的信 提交于 2019-12-04 18:10:02
If the project is re-deployed through netbeans on tomcat 7 then I get errors like java.lang.IllegalStateException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at com.mchange.v2.resourcepool.BasicResourcePool.checkIdleResources(BasicResourcePool.java:1481) at com.mchange.v2.resourcepool.BasicResourcePool.access$2000(BasicResourcePool.java:32) at com.mchange.v2.resourcepool.BasicResourcePool$CheckIdleResourcesTask.run(BasicResourcePool.java:1964) at java.util

Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvid

岁酱吖の 提交于 2019-12-04 16:27:52
最近有一个老项目做二开,项目使用了SSH架构,c3p0作为数据库连接池,但是项目启动的时候,tomcat会卡在下面这行代码: Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 很久之后,tomcat会抛出异常: Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at org.quartz.utils

Configuring C3P0 in Persistence.xml with JPA and Hibernate

为君一笑 提交于 2019-12-04 11:57:36
Well, i'm trying to configure for first time the C3P0 with JPA + Hibernate + Spring. In persistence.xml i have: <properties> <property name="hibernate.show_sql" value="false" /> <property name="hibernate.format_sql" value="false" /> <property name="hibernate.hbm2ddl.auto" value="update" /> <property name="hibernate.cache.use_second_level_cache" value="false" /> <property name="hibernate.cache.use_query_cache" value="false" /> <property name="hibernate.jdbc.batch_size" value="50" /> <!-- Important --> <property name="hibernate.connection.provider_class" value="org.hibernate.connection

java数据库连接池

别来无恙 提交于 2019-12-04 11:14:50
web项目都会使用数据库,而数据库访问会影响系统性能(I/O操作)。建立数据库连接是一个非常耗时耗资源的操作,通过配置连接池可以在系统启动时就分配并维护一定数量的连接,保持最低数量的连接数,通过设定连接池最大连接数来防止系统无尽的与数据库连接。这样在每次数据请求方需要连接时,直接从连接池获取,使用完毕之后再放回去,这样就可以尽可能减少不必要的数据库连接消耗,缓解数据库的访问压力,减轻对系统性能的影响。 java常用的数据库连接池主要有 DBCP 和 C3P0; 一、DBCP DBCP(DataBase connection pool),数据库连接池。是 apache 上的一个 Java 连接池项目,也是Tomcat 在 7.0 以前的版本使用的连接池组件。 使用DBCP应该导入commons-dbcp-x.x.jar、commons-pool-x.x.jar、commons-logging-x.x.jar commons-dbcp最新版本是 Apache Commons DBCP 2.1.1 for JDBC 4.1 (Java 7.0+) Apache Commons Pool 2.4.2 (Java 6.0+) Apache Commons Logging 1.2 测试实例 TestDBCP.java package cn.iborder.utils; import java

Connection time out issues after inactivity period

女生的网名这么多〃 提交于 2019-12-04 09:38:42
问题 We have an api which uses hibernate as ORM tool and we use c3p0 as the connection pool handler. We have no problems when we are under load. However, we are running out into "unable to obtain a connection" exceptions when the api has been inactive for a day or so. So, if no body uses the api over the weekend, we get connection errors on monday morning. Caused by: java.sql.SQLException: An attempt by a client to checkout a Connection has timed out. We use mysql as the database. On my research,

hibernate.cfg.xml

谁说我不能喝 提交于 2019-12-04 06:59:32
配置JDBC的连接: <!--配置数据库的驱动程序,Hibernate在连接数据库时,需要用到数据库的驱动程序--> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <!--设置数据库的连接url:jdbc:mysql://localhost/hibernate,其中localhost表示mysql服务器名称,此处为本机, hibernate是数据库名--> <property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate</hibernate> <!--连接数据库是用户名--> <property name="hibernate.connection.username">root</property> <!--连接数据库是密码--> <property name="hibernate.connection.password">123456</property> <!--数据库连接池的大小--> <property name="hibernate.connection.pool.size">20</property> 2.配置c3p0连接池: <!-

Preemptively and gracefully check that org.hibernate.Session is still connected (via c3p0)

匆匆过客 提交于 2019-12-04 06:16:07
问题 I am working in a multisharded database environment in which downtime of a shard is not a fatal occurrence. When the application starts, all the shard info is loaded in a cache and respective Session objects loaded, however, it is expected that during the application uptime some of the shards may go down, in which case the application fails over to one of the remaining shards. It is almost a standard use case scenario. In some cases, I need to do a cross-shard scan and the way I do it is

c3p0引起的数据库死锁问题

核能气质少年 提交于 2019-12-04 04:49:13
代码测试本地无误,于是放到外网服务器测试,出现了这样的错误 com.mchange.v2.async.ThreadPoolAsynchronousRunner - 46651078 [Timer- 18 ] WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector @1c17bd4 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 看到这个头都大了,怎么办呢?为什么出现这样的情况? 我的答案是: 因为数据库的连接数是有限的,每次应用启动C3p0都会占用数据库的连接来填充C3p0的连接池,而当数据库的资源被占光时就会因为无法获得共享资源而报死锁。 更改对应配置文件里面的最大连接数和初始化连接数: 未改前: <property name="maxPoolSize" value="100" /> <property name="initialPoolSize" value="2" /> 修改之后: <property name="maxPoolSize" value="1" />

APPARENT DEADLOCK!!! 错误解决过程

╄→尐↘猪︶ㄣ 提交于 2019-12-04 04:48:55
项目环境 数据库:oracle 中间件:WAS 2. 问题描述 2015.05.21(是个好日子),早上发现was后台报错如下: [15-5-21 7:31:01:171 CST] 00000027 SystemErr R com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@498e498e -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 3.问题解决过程 从网上百度下这个错误,分析大致如下: 原因是 hibernate 使用c3p0连接orcale数据后不会释放 , c3p0的最大连接数为100,但显然c3p0有Bug,导致数据库连接池不够用,导致进程锁死。 后换Proxool后,观察正常。 参考网址: http://blog.csdn.net/chinesesword/article/details/7902702 http://blog.sina.com.cn/s/blog_5491164b0100sxtc.html http://myzee.blog.163.com/blog/static/2088712420121110139423/ http://www.blogjava