Thursday, November 23rd, 2017

Stream has already been closed; nested exception is java.sql.SQLException in Oracle.

0

Stream has already been closed; nested exception is java.sql.SQLException in Oracle

In this sample code, an exception occured i.e “Stream has already been closed; nested exception is java.sql.SQLException”, In case java – Oracle connectivity this kind of exception thrown out. Reason for this exception, the table contains a datatype (long) field.

sample code

selProcess = conn.prepareStatement  (“select data(this is Long raw column),
intername, transid, transorder, errorcount, emailsent from max_interdata
order by transid, transorder, rowstamp”);

ResultSet rsetMax = selProcess.executeQuery();

try
{
while (rsetMax.next())
{

//08/15/02, JB — using getBinaryStream() instead
of getBytes() to
//work around Oracle driver bug
InputStream inputStream = null;
try
{
inputStream = rsetMax.getBinaryStream(1);
data = readBinaryData(inputStream);
// method to convert the inputsream to my object
interfaceName = rsetMax.getString(2);
transID = rsetMax.getLong(3);
transOrder = rsetMax.getLong(4);
errorCount = rsetMax.getInt(5);
emailSent =  rsetMax.getString(6);
}

000.         000: String.java.lang.String:Stack trace:
java.sql.SQLException: Stream has already been closed
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)
at
oracle.jdbc.dbaccess.DBDataSetImpl.getStreamItem(DBDataSetImpl.java:1145)
at
oracle.jdbc.driver.OracleStatement.getBinaryStreamValue(OracleStatement.java:4616)
at
oracle.jdbc.driver.OracleResultSetImpl.getBinaryStream(OracleResultSetImpl.java:398)
at
psdi.iface.interdata.MaxInterDataBatch.processInterData(MaxInterDataBatch.java:150)
at
psdi.iface.mic.MicService$PollMaxInterdataBatch.run(MicService.java:1723)
at java.lang.Thread.run(Thread.java:484)
For example:

‘Customer is the table name contains a field ‘order’ long datatype

To solve this exception, replace the datatype ‘long‘ field to ‘number‘ datatype

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • RSS
  • Technorati
  • Twitter

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Secure Linux Web Hosting