We have recently upgraded Oracle database from 11g release2 to 19c.
Now we have Oracle 19c database server, JDK 1.8 and ojdbc6.jar combination.
We have some java code to create JDBC Statement object with scrollable and concurrent read only ResultSet feature. With the mentioned combination JDBC query execution is failing with following error
Approach1:
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet resultSet = statement.executeQuery(query);
Post upgrade statement.executeQuery() method is throwing following Exception
java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:4477)
at oracle.jdbc.driver.OracleStatement.clearWarnings(OracleStatement.java:3430)
at oracle.jdbc.driver.OracleStatement.prepareForNewResults(OracleStatement.java:3946)
at oracle.jdbc.driver.OracleStatement.doScrollExecuteCommon(OracleStatement.java:5246)
at oracle.jdbc.driver.OracleStatement.doScrollStmtExecuteQuery(OracleStatement.java:5302)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1325)
at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:422)
at JDBCConnectionUtilDebug.getQueryOutput(JDBCConnectionUtilDebug.java:294)
But if I run same sql query using following approach, then it works fine
Approach2:
Statement stat = connection.createStatement();
boolean ret = stat.execute(query");
if (ret) {
ResultSet rs = stat.getResultSet();
Any help/pointer why Approach1 is failing but Approach2 is working?
Thank you both @Mark Rotteveel and @ibre5041 for your response.
As per [What are the Oracle JDBC releases Vs JDK versions?] https://www.oracle.com/in/database/technologies/faq-jdbc.html
The combination 19C database, java 1.8 and ojdbc6.jar is not compatible.
Oracle Database version
19.x
JDBC Jar files specific to the release
After using ojdbc8.jar instead of ojdbc6.jar both query execution approaches working fine.