java.sql.SQLException: Stream has already been closed When Running Query In JDBC

(Doc ID 832903.1)

Last updated on MARCH 08, 2017

Applies to:

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


An application using JDBC to connect to a 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

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

public class JDBCAssignment {
public static void main(String[] args) {
Connection conn = null;
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");

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){


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