Two Laptop Bag*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem in inserting to BLOB field" Watch "Problem in inserting to BLOB field" New topic
Author

Problem in inserting to BLOB field

Vishnu Murthy
Ranch Hand

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

String templateText = notifyTemplateBean.getTemplateText();

ByteArrayInputStream byteArrStream = null;

try
{
byteArrStream =new ByteArrayInputStream( templateText.getBytes(ENCODING_CHARSET_ISO88591));
}catch(UnsupportedEncodingException uee)
{
// should never happen
}
query = " INSERT INTO X_NTFY_TMPLT_CONTENT_TABLE
(OBJID, X_TMPLT_CONTENT) VALUES( ?, ? )";
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.
ojdbc14.jar.

-Thank you
Vishnu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in inserting to BLOB field