java.sql.SQLException: Stream has already been closed When Running Query In JDBC 10.2.0.4 (Doc ID 832903.1)

Last updated on MARCH 08, 2017

Applies to:

JDBC - Version: 10.2.0.4 and later   [Release: 10.2 and later ]
Information in this document applies to any platform.
***Checked for relevance on 11-Nov-2010***

Symptoms

An application using JDBC 10.2.0.4 to connect to a 10.2.0.4 database to generate ad hoc reports
fails with error:

java.sql.SQLException: Stream has already been closed


The same query runs fine through SQLDeveloper.

This only appears to happen when the query includes a column with a type of Long.

For example, standalone program JDBCAssignment.java.:

import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.OracleDriver;
import javax.naming.*;

public class JDBCAssignment {
public static void main(String[] args) {
Connection conn = null;
try{
DriverManager.registerDriver(new OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:@<host>:<port>:<db>","<user>","<pwd>");
System.out.println("Connection successful");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select ID, DESCRIPTION, RESULT_DETAIL from enrole.PROCESS");

Statement st1 = conn.createStatement();
ResultSet rs1 = st1.executeQuery("select DN from enrole.ACCOUNT");

while(rs.next()){
System.out.println("ID : " + rs.getString(1));
System.out.println("DESCRIPTION : " + rs.getString(2));
System.out.println("RESULT_DETAIL : " + rs.getString(3));
}
} catch(SQLException e){
e.printStackTrace();
}
}
}



Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms