Not able to load image more than 4kb Oracle- JDBC
java.sql.SQLException: Data size bigger than max size for this type:
and
java.sql.SQLException: Io exception: Connection reset by peer.
Dear All,
This two exception is thrown when i m trying to insert an image which is more than 4kb.
1st exception is thrown when i m setting through pstmt.setBytes(); and 2nd one is when i m setting through pstmt.setBinaryStream();
But i m able to upload when the size is less than 4kb. Any body suggest what i m doing wrong in this code or what i need to do to get out of this problem.
Here is the code:
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
boolean flag = false;
File f = null;
try {
f = new File(absPath);
conn = DBUtils.getDBConnection(DBUtils.DATASOURCE_NAME);
pstmt = conn.prepareStatement("INSERT INTO XXXXX values(XXXX_SEQ.nextval, ?)" );
FileInputStream fis=new FileInputStream(f);
byte[] bytes= new byte[fis.available()+1];
fis.read(bytes);
pstmt.setBytes(1,bytes);
// pstmt.setBinaryStream(1, fis, (int)f.length());
int test = pstmt.executeUpdate();
pstmt.close();
fis.close();
if(test >= 1){
log.info("inserted ");
}
else{
log.info("not inserted");
}
}
catch(SQLException se){
se.printStackTrace();
}
catch(FileNotFoundException fe){
fe.printStackTrace();
}
catch(IOException ioex)
{
ioex.printStackTrace();
}
finally{
DBUtils.closeAll(pstmt, rs, conn);
}
--------
The exception is throughing when it is trying to update the db using "executeUpdate()".
Please give any example, if i can refer to