alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.9k stars 8.57k forks source link

Cause: java.sql.SQLException: ORA-02399: exceeded maximum connect time, you are being logged off #2492

Open LesterDong opened 6 years ago

LesterDong commented 6 years ago

程序中报数据库的异常,错误栈如下: java.sql.SQLException: ORA-01012: not logged on

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:810)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:850)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)

-- at com.chinagpay.notifyer.listener.NotifyMerListener$1.run(NotifyMerListener.java:78) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

经排查,发现有另外一个异常: SQL []; ORA-02399: exceeded maximum connect time, you are being logged off ; nested exception is java.sql.SQLException: ORA-02399: exceeded maximum connect time, you are being logged off ,我在想是不是连接池中某些连接在调用时发现oracle服务端已经将该连接物理关闭了,但是在druid连接池中还是alived,druid参数配置如下: `

    <property name="username" value="${kydb.db.writer.username}" />
    <property name="password" value="${kydb.db.writer.password}" />
    <property name="connectionProperties"
        value="config.decrypt=true;config.decrypt.key=${db.publicKey}" />
    <property name="initialSize" value="${kydb.db.initialSize}" />
    <property name="maxActive" value="${kydb.db.maxActive}" />
    <property name="minIdle" value="${kydb.db.minIdle}" />
    <property name="maxWait" value="${kydb.db.maxWait}" />
    <property name="defaultReadOnly" value="false" />
    <property name="proxyFilters">
        <list>
            <ref bean="stat-filter" />
        </list>
    </property>
    <property name="filters" value="${druid.filters}" />
    <property name="testWhileIdle" value="true" />
    <property name="testOnBorrow" value="false" />
    <property name="testOnReturn" value="false" />
    <property name="validationQuery" value="select 1 from dual" />
    <property name="minEvictableIdleTimeMillis" value="3000000" />
    <property name="timeBetweenEvictionRunsMillis" value="3000" />
    <property name="timeBetweenLogStatsMillis" value="1000" />
    <property name="statLogger" ref="myStatLogger" />`
wenshao commented 6 years ago

这儿是服务器的问题,不对druid的问题

LesterDong commented 6 years ago

@wenshao 大神 这个大概什么问题 怎么解决呢 可否指点一下

LesterDong commented 6 years ago

@wenshao 我看了#870,根据我查找的其他资料应该是这个问题,oracle服务端配置的CONNECT_TIME=60,就是服务端允许的物理连接最长是60分钟,druid配置了testWhileIdle=true和timeBetweenEvictionRunsMillis=600000,validationQuery=select 1 from dual ,感觉这个只能起到检查连接是否是活的这样的作用。现在可以确定被服务端强制关闭的连接一定是一直在应用端被使用而没有被回收,现在想知道什么办法能实现连接在配置了超时时间后必须强制回收?druid某个参数可以达到这个效果么?请大神能够指点下 感激!