更改会话挂起或导致ORA-01013

问题描述

我有以下代码块,并且在执行ALTER SESSION语句时,它挂起或抛出ORA-01013,这取决于我们是连接到Oracle 12r2还是19.3,以及哪个版本的OJDBC8驱动程序正在被使用:

try(Connection connection = jdbcConnection.connect(false)) {
  // We now have a java.sql.Connection open to the database at this point
  try(PreparedStatement ps = connection.prepareStatement(someQuery)) {
    // We not have a prepared statement based on query,the query is irrelevent
    try (Statement s = connection.createStatement()) {
      // The following statement fails with the ORA-01013 error
      s.execute("ALTER SESSION SET CONTAINER=" + pdbName);
    }
  }
}

如果我将此代码块重做以下内容,问题将消失。

try(Connection connection = jdbcConnection.connect(false)) {
  // We now have a java.sql.Connection open to the database at this point
  try (Statement s = connection.createStatement()) {
    s.execute("ALTER SESSION SET CONTAINER=" + pdbName);
  }
  try(PreparedStatement ps = connection.prepareStatement(someQuery)) {
    // We not have a prepared statement based on query,the query is irrelevent
  }
  // or put the alter session here
}

根据我的判断,使用Oracle OJDBC8 12.2.0.1会抛出hang或ORA-01013异常;但是,当我迁移到19.x.0.0时,这就是发生此问题的地方。

这是JDBC驱动程序中的错误吗,还是代码编写方式上确实存在问题,即12.2.0.1驱动程序比以后的版本更宽容?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...