BinaryStream with PreparedStatements
i'm working with binaryStream in prepared statements.
this is my code (a simpier version):
Code:
FileInputStream fis = new FileInputStream([COLOR="Green"]myFileBiggerThanJVMHeapMemory[/COLOR]);
{....}//obvious code to set the database connection ignored for simplicity
PreparedStatement ps;
sqlStatement="INSERT INTO `files` VALUES(0,?,?,?,?);"
ps = conn.prepareStatement(sqlStatement, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ps.setString(1, [COLOR="Green"]myFileBiggerThanJVMHeapMemory[/COLOR].getName());
ps.setInt(2, myIntID);
ps.setString(3, myString);
[COLOR="Red"]ps.setBinaryStream(4, fis, fis.getChannel().size());[/COLOR]
ps.executeUpdate();
i start saying that this code works fine and insert everything in each DB column without warning , Exception or anything else...
BUT if the file i'm going to set is bigger than 12-13 MB ... i receive an HeapOutOfMemory.... i thought that binary Streams do not have any limited dimension ...but probably i'm wrong... is it possible to resolve this problem with preparedStatement? or do i need other solutions?
thanks