Oracle Alter会话挂起或导致ORA-01013

Oracle Alter会话挂起或导致ORA-01013,oracle,oracle12c,ojdbc,oracle19c,Oracle,Oracle12c,Ojdbc,Oracle19c,我有以下代码块,当执行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(PreparedSt

我有以下代码块,当执行
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,将抛出挂起或ORA-01013异常;然而,当我迁移到19.x.0.0时,我发现这个问题就发生在这里


这是JDBC驱动程序中的一个错误,还是12.2.0.1驱动程序比更高版本更宽松的代码编写方式确实存在问题?

只是一个想法:您是通过服务(url中的服务名称)还是SID进行连接?我还假设您使用的是一个全局用户,对吗?只是想一想:您是通过服务(url中的服务名称)还是SID进行连接?我还假设您使用的是全局用户,对吗?