【问题标题】:The connection is closed when using Oracle UCP使用 Oracle UCP 时连接关闭
【发布时间】:2016-04-06 01:56:41
【问题描述】:

使用 Oracle UCP v 12.1.0.2.0 时出现随机“连接已关闭:连接已关闭”错误。看起来连接被标记为已关闭 oracle.ucp.jdbc.proxy.JDBCConnectionProxyFactory#invoke :

if(Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getAvailableStartTime()) || Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getBorrowedStartTime())) {
      this.m_closed = Boolean.valueOf(true);
}

Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getAvailableStartTime()) 返回 true。

有人能解释一下这张支票的用途吗?

getAvailableStartTime 是在连接返回池时设置的,creationTS - 是在创建 JDBCConnectionProxyFactory 时设置的,它是在放弃连接时创建的。

isBefore 看起来像这样:

public static boolean isBefore(long time1, long time2) {
        return time1 < time2 - 1000L;
}

那么,在不到一秒前返回连接的情况是否是条件?

ps:尝试过验证查询“select 1 from dual” - 无效

【问题讨论】:

    标签: oracle jdbc ucp


    【解决方案1】:

    如果Clock.isBefore(this.creationTS, this.m_jdbcPooledConnection.getAvailableStartTime()) 返回true,则意味着UCP 已重新收集连接并使其再次可用。如果您在 UCP 中打开连接收集,通常会发生这种情况。 UCP 检测何时借用连接但未使用时间过长(设计不佳的应用程序),并为避免连接泄漏,它将抢回连接并使其在池中可用。如果原始线程随后唤醒并尝试使用连接,则会收到 connection is closed 错误。

    【讨论】:

      猜你喜欢
      • 2017-06-19
      • 2016-12-10
      • 1970-01-01
      • 2015-06-15
      • 1970-01-01
      • 2011-01-26
      • 2019-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多