在使用SSH框架时遇到个c3p0的问题,或出现下面的两个错误:
DEBUG STACK TRACE for PoolBackedDataSource.close().
和
DEBUG -- CLOSE BY CLIENT STACK TRACE
而且时有时无,网络上说不管他,不影响其他操作,不过我这确啥也干不了。所以我换了个dataSource
之前的dataSource是这样配置的:(需要导入c3p0-0.9.1.2.jar包)
XML/HTML代码
- < bean id = "dataSource"
- class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method = "close" >
- < property name = "driverClass" value = "oracle.jdbc.driver.OracleDriver" > </ property >
- < property name = "jdbcUrl" value = "jdbc:oracle:thin:@localhost:1521:orcl" > </ property >
- < property name = "user" value = "scott" > </ property >
- < property name = "password" value = "scott" > </ property >
- < property name = "maxPoolSize" value = "40" />
- < property name = "minPoolSize" value = "1" />
- < property name = "initialPoolSize" value = "1" />
- < property name = "maxIdleTime" value = "200" />
- </ bean >
我换成了dbcp的dataSource,配置如下:(需要导入commons-dbcp.jar和commons-pool.jar两个包)
- < bean id = "dataSource"
- class = "org.apache.commons.dbcp.BasicDataSource" >
- < property name = "driverClassName" value = "oracle.jdbc.driver.OracleDriver" > </ property >
- < property name = "initialSize" value = "10" > </ property >
- < property name = "maxActive" value = "300" > </ property >
- < property name = "url" value = "jdbc:oracle:thin:@localhost:1521:orcl" > </ property >
- < property name = "username" value = "scott" > </ property >
- < property name = "password" value = "scott" > </ property >
- </ bean >
就没遇到问题了。
PS:(7-23)今天又有新问题了,这个DBCP的连接池出现了下面的异常:
Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin failed:
好像是因为不支持重连,所以又换回c3p0,不过多配置了重连参数:
- < bean id = "dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method = "close" >
- < property name = "driverClass" value = "oracle.jdbc.driver.OracleDriver" > </ property >
- < property name = "jdbcUrl" value = "jdbc:oracle:thin:@localhost:1521:orcl" > </ property >
- < property name = "user" value = "scott" > </ property >
- < property name = "password" value = "scott" > </ property >
- < property name = "maxPoolSize" value = "40" />
- < property name = "minPoolSize" value = "1" />
- < property name = "initialPoolSize" value = "1" />
- < property name = "maxIdleTime" value = "200" />
- < property name = "idleConnectionTestPeriod" value = "200" />
- < property name = "preferredTestQuery" value = "select * from hr_attendtype" />
- < property name = "testConnectionOnCheckin" value = "true" />
- < property name = "testConnectionOnCheckout" value = "true" />
- </ bean >