2

我正在使用带有薄 jdbc 驱动程序的 Spring 使用 Oracle Native 连接池,并注意到以下错误

Exception in thread "main" org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLRecoverableException: IO Error: Connection reset
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:382)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:519)
Caused by: java.sql.SQLRecoverableException: IO Error: Connection reset
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:428)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
    at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:207)
    at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPhysicalConnection(OracleConnectionPoolDataSource.java:139)
    at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPooledConnection(OracleConnectionPoolDataSource.java:88)
    at oracle.jdbc.pool.OracleImplicitConnectionCache.makeCacheConnection(OracleImplicitConnectionCache.java:1583)
    at oracle.jdbc.pool.OracleImplicitConnectionCache.makeOneConnection(OracleImplicitConnectionCache.java:515)
    at oracle.jdbc.pool.OracleImplicitConnectionCache.defaultUserPrePopulateCache(OracleImplicitConnectionCache.java:222)
    at oracle.jdbc.pool.OracleImplicitConnectionCache.<init>(OracleImplicitConnectionCache.java:198)
    at oracle.jdbc.pool.OracleConnectionCacheManager.createCache(OracleConnectionCacheManager.java:306)
    at oracle.jdbc.pool.OracleConnectionCacheManager.createCache(OracleConnectionCacheManager.java:192)
    at oracle.jdbc.pool.OracleDataSource.cacheInitialize(OracleDataSource.java:414)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:393)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:179)
    at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
    ... 5 more
    Caused by: java.net.SocketException: Connection reset
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
    at oracle.net.ns.DataPacket.send(DataPacket.java:199)
    at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:211)
    at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:227)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
    at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:123)
    at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:79)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1122)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1099)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:288)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366)
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:752)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:366)
    ... 25 more

下面是spring配置文件中数据源的配置方式

<bean id="datasourceone" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
    <property name="connectionCachingEnabled" value="true" />
    <property name="URL">
        <value>jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=xyz-01) (PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=xyz-02) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ABCD)))</value>
    </property>
    <property name="user">
        <value>XYZ</value>
    </property>
    <property name="password">
        <value>XXXX</value>
    </property>
    <property name="connectionCacheProperties">
        <value>
            MinLimit:1
            MaxLimit:5
            InitialLimit:1
            ConnectionWaitTimeout:120
            InactivityTimeout:180
            ValidateConnection:true
        </value>
    </property>
</bean>

如果有人可以提供任何相同的建议,强烈推荐吗?调整连接池有帮助吗?如果是,是否有任何具体需要调整的内容?

4

2 回答 2

2

尝试使用不同的连接池实现并检查是否看到相同的错误。

于 2013-04-01T20:25:18.997 回答
0

试试这个作为连接字符串:

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xyz-01)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=xyz-02)(PORT=1521))(LOAD_BALANCE=on))(CONNECT_DATA=(SERVICE_NAME=ABCD)))

并再次测试。

于 2013-03-29T14:23:30.737 回答