This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Problem in inserting to BLOB field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem in inserting to BLOB field" Watch "Problem in inserting to BLOB field" New topic

Problem in inserting to BLOB field

Vishnu Murthy
Ranch Hand

Joined: Jan 04, 2001
Posts: 56
When I am trying to insert the value into Blob field using the following code.

String templateText = notifyTemplateBean.getTemplateText();

ByteArrayInputStream byteArrStream = null;

byteArrStream =new ByteArrayInputStream( templateText.getBytes(ENCODING_CHARSET_ISO88591));
}catch(UnsupportedEncodingException uee)
// should never happen
previewPstmt = connection.prepareStatement( query);
previewPstmt.setInt(1, Integer.parseInt(notifyTemplateBean.getTemplateID()));
previewPstmt.setBinaryStream(2, byteArrStream, byteArrStream.available());
int success = previewPstmt.executeUpdate( );

The insertion is successful when byteArrStream is of size <=4000 (4 thousands bytes), if the byteArrStream size if more then 4000 bytes it is through the following Exception

java.sql.SQLException: Io exception: Connection reset by peer: socket write error

I am struck with this problem from the last few days. Any help is appreicated.

I am using Oracle9i database, JBoss4.0.5 server, JDK1.5.

-Thank you
I agree. Here's the link:
subject: Problem in inserting to BLOB field
It's not a secret anymore!