SQLException: Stream has already been closed (Oracle)

Ok I have an Oracle DB with a table where one column is of type LONG. I have a select statement on that table:

SELECT COL1, COL2

FROM TABLE

WHERE

SOME CONDITION

COL2 is the LONG column.

I get the ResultSet and do:

String col1 = getString(1);

byte[] bytes = getBytes(2);

Sometimes this will work sometimes it throws an SQLException with Stream has already been closed.

This code is hit about 5 times in the one execution of the program but only fails once in about 3 runs of the program.

Has anyone encountered this itermitent behavior before on Oracle 10 using the thick driver?

[686 byte] By [Ydassaca] at [2007-10-2 14:24:13]
# 1
You might want to speak to the threading issue because that would be my first question about your problem.
Ydassaca at 2007-7-13 12:43:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
> You might want to speak to the threading issue> because that would be my first question about your> problem.The application is single threaded, there are no multiple threads being used.
Ydassaca at 2007-7-13 12:43:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
Is column 2 nullable or zero / default value?
darteda at 2007-7-13 12:43:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
No column 2 is populated and NOT NULL
Ydassaca at 2007-7-13 12:43:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

> Sometimes this will work sometimes it throws an

> SQLException with Stream has already been closed.

> This code is hit about 5 times in the one execution

> of the program but only fails once in about 3 runs of

> the program.

What does the stack trace say?

aniseeda at 2007-7-13 12:43:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

From the Oracle docs,

http://www.lc.leidenuniv.nl/awcourse/oracle/java.920/a96654/basic.htm#1002507

http://www.lc.leidenuniv.nl/awcourse/oracle/java.920/a96654/basic.htm#1021780

The second section deals with precautions for using streaming data. The example provided illustrates that you need to access the stream data columns immediately. I hope this helps you.

aniseeda at 2007-7-13 12:43:16 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...