This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
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
subject: Problem in inserting to BLOB field
Similar Threads
Image insertion into database through JPA
Image insertion into database
Reading From a Binary Large Object(BLOB)
Oracle Datasource Connection
Not able to insert image more than 4K in Database