Hi,
If i store binary data (actual photo's) into H2 in *one* transaction i
run into memory problems when using VARBINARY. If i use BLOB's
everything goes well. See code sample. Is this a H2 issue or do I miss
a configuration option?
final Properties props = new Properties();
props.setProperty("USER", "admin");
props.setProperty("PASSWORD", "admin");
props.setProperty("MAX_MEMORY_UNDO", "100");
Class.forName("org.h2.Driver");
final Connection c = DriverManager.getConnection("jdbc:h2:./
test", props);
c.setAutoCommit(false);
final Statement stm = c.createStatement();
//stm.executeUpdate("create table TEST (id IDENTITY, data
BLOB)"); // OK
stm.executeUpdate("create table TEST (id IDENTITY, data
VARBINARY)"); // OOM
stm.close();
final PreparedStatement pstm = c.prepareStatement(
"INSERT INTO test (data) VALUES (?)");
// H2 keeps the undo log in memory by default, MAX_MEMORY_UNDO
must be set
// to a low value if memory is limited
// When using VARBINARY and -Xmx128M OoM always occurs
int count = 0;
while (++count < 100) {
pstm.setBytes(1, new byte[1024 * 1024]);
pstm.executeUpdate();
}
c.commit();
c.close();
Regards,
Ronald
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.