随机获取java.net.SocketException:连接重置

时间:2018-06-06 15:07:43

标签: java spring oracle spring-jdbc

我在我的应用上随机获得以下异常。它发生在我的应用程序尝试查询数据库时。有些日子,我的应用程序能够连接到oracle 12c(v12.1.0.2.0)数据库。其他几天它失败了,下面的堆栈跟踪。我正在使用ojdbc6.jar连接到数据库。 任何导致此错误的帮助都将不胜感激。

数据源配置:

<bean id="hlpDataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="url" value="url" />
    <property name="username" value="user" />
    <property name="password" value="password" />
    <property name="initialSize" value="30"/>
    <property name="minIdle" value="10" />
    <property name="validationQuery" value="Select 1 from dual" />
    <property name="maxIdle" value="100"/>
    <property name="maxActive" value="100"/> 
    <property name="maxWait" value="30000"/>
    <property name="testOnBorrow" value="true"/>
    <property name="removeAbandonedTimeout" value="120"/>
    <property name="removeAbandoned" value="true"/>
    <property name="validationQueryTimeout" value="30" />
</bean>

例外:


    Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (IO Error: Connection reset)
        at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:394)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:478)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:488)
        at org.springframework.jdbc.core.JdbcTemplate.queryForList(JdbcTemplate.java:514)
        ... 22 more
    Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (IO Error: Connection reset)
        at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
        at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
        at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
        ... 29 more
    Caused by: java.sql.SQLRecoverableException: IO Error: Connection reset
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:752)
        at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:666)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:566)
        at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
        at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
        at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
        at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
        ... 33 more
    Caused by: java.net.SocketException: Connection reset
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:115)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
        at oracle.net.ns.DataPacket.send(DataPacket.java:209)
        at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:215)
        at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:302)
        at oracle.net.ns.NetInputStream.read(NetInputStream.java:249)
        at oracle.net.ns.NetInputStream.read(NetInputStream.java:171)
        at oracle.net.ns.NetInputStream.read(NetInputStream.java:89)
        at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:123)
        at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:79)
        at oracle.jdbc.driver.T4CMAREngineStream.unmarshalUB1(T4CMAREngineStream.java:429)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:397)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:437)
        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:954)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:639)
        ... 40 more

0 个答案:

没有答案