This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle Blob using Java help (Error: JVM_recv in socket input stream read )

 
Rashmi Banthia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to insert a record with Blob column (size of image 'mg.jpg' about 15KB) and I get the runtime error:
[java] java.sql.SQLException: Io exception: Connection reset by peer: JVM_recv in socket input stream read
[java] at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
[java] at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
[java] at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
[java] at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2061)
[java] at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
[java] at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
[java] at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
[java] at test.ProvisioningParser.TestBlob.main(Unknown Source)

This is what code looks like: I am not sure what's wrong, any help appreciated. Thanks!
try{

Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc racle:thin:@VALUED-20606295:1521 bbook","jvending","jvending");


java.util.zip.ZipInputStream zip = new java.util.zip.ZipInputStream(new java.io.FileInputStream(new java.io.File("D:\\work\\mywork\\source\\test\\ProvisioningParser\\test.par"))) ;
int len = 0 ;
java.util.zip.ZipEntry entry = null;
do{
entry = zip.getNextEntry();
if (entry != null){
if (entry.getName().equalsIgnoreCase("mg.jpg")){
len = (int)entry.getSize();
break;
}
}
}while(entry!=null) ;

stmt = con.prepareStatement( "Insert into icon (parid, clientbundleid, id, iconfile ) values ( ?,?,?,?)"
);
stmt.setString(1,"101");
stmt.setString(2,"101");
stmt.setInt(3,1);
stmt.setBinaryStream( 4, zip, len);
stmt.setQueryTimeout(0);
stmt.executeUpdate();

con.close();
}
catch(Exception e){
e.printStackTrace();
}

Thanks,
Rashmi
 
Rashmi Banthia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured this, I was using thin driver instead of OCI. With OCI (for >4K blobs) it works fine.
Regards,
Rashmi
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic