Dear All
I keep clicking the data to h2 by stmt.addBatch(), after i called executeBatch, memory is not free, so finally out of memory, may i know why please?
@Override
public void run() {
while (!stopped) {
synchronized (sharedLock) {
try {
// System.out.println("data.size() =" + data.size());
for (int z = 0; z < data.size() && z < 100000; z++) {
Object[] temp;
synchronized (data) {
temp = data.pollLast();
}
int x = 1;
stmt.setLong(x++, (Long) temp[0]);
stmt.setString(x++, (String) temp[1]);
stmt.setString(x++, (String) temp[2]);
stmt.setString(x++, (String) temp[3]);
stmt.setInt(x++, (int) temp[4]);
for (int tempX = 0; tempX < registers.size(); tempX++) {
stmt.setLong(x, ((BigInteger) temp[x - 1]).longValue());
x++;
}
stmt.addBatch();
}
if (data.size() % 100000 == 0 || data.size() < 100000) {
stmt.executeBatch();
conn.commit();
}
} catch (SQLException ex) {
Logger.getLogger(H2Thread.class.getName()).log(Level.SEVERE, null, ex);
}
}
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
Logger.getLogger(H2Thread.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
thanks