日期:2014-05-18  浏览次数:20778 次

从连接池获取连接时出现Got minus one from a read call异常
本帖最后由 liuwei_blog 于 2010-11-29 15:50:49 编辑
在测试中
如果只有一个方法连接数据库,准失败抛出Got minus one from a read call异常。
如果有2个方法查询数据库,通常第一个方法失败抛出Got minus one from a read call异常,第二个方法成功。
JDBC 基本正常,偶尔也会抛出Got minus one from a read call异常,几率很小。
怀疑主要是连接池的问题,数据库可能也有问题,连接池配置如下:

<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@192.168.0.100:1521:orcl</value>
</property>
<property name="username">
<value>user</value>
</property>
<property name="password">
<value>123456</value>
</property>
<property name="initialSize">
<value>10</value>
</property>
<property name="maxActive">
<value>600</value>
</property>
<property name="maxIdle">
<value>100</value>
</property>
<property name="minIdle">
<value>1</value>
</property>
<property name="maxWait">
<value>6000</value>
</property>
<property name="timeBetweenEvictionRunsMillis">
<value>200</value>
</property>
<property name="minEvictableIdleTimeMillis">
<value>3000</value>
</property>
<property name="numTestsPerEvictionRun">
<value>1</value>
</property>
<property name="validationQuery">
<value>select sysdate from dual</value>
</property>
<property name="testOnBorrow">
<value>false</value>
</property>
<property name="testOnReturn">
<value>false</value>
</property>
<property name="testWhileIdle">
<value>false</value>
</property>
</bean>

报错信息如下:
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.SQLNestedException: Error preloading the connection pool
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:241)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:336)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
at com.ihandy.yuncai.studi