Hi,
I have a little routine, that is supposed to delete some records after a
certain due date.
It looks like the following:
public void reorganize(long defermentPeriod)
{
m_strBuf.delete(0, m_strBuf.length());
m_strBuf.append("delete from MEMO_RECORDS").append("\n")
.append("where TMPST_USED >= ?");
PreparedStatement pStmtRecord = null;
try
{
pStmtRecord =
m_conn.prepareStatement(m_strBuf.toString());
long dueDate = new
java.util.Date().getTime()+defermentPeriod;
pStmtRecord.setTimestamp(1, new Timestamp(dueDate));
pStmtRecord.execute();
SimpleDateFormat dForm = new
SimpleDateFormat("dd.MM.yyyy-HH:mm:ss:SSS");
logger.debug("cut off date:"+dForm.format(new
Date(dueDate)));
if (pStmtRecord.getUpdateCount()>0)
{
logger.info("deleted records by
reorganisation:"+pStmtRecord.getUpdateCount());
}
}
catch (SQLException sqlEx)
{
throw new RuntimeException(sqlEx);
}
finally
{
try
{
pStmtRecord.close();
}
catch (Throwable th)
{
logger.trace("trouble closing
pStmtQRecord!",th);
}
}
}
Unfortunately it does not quite that I expect. It seems that it does not
really fined the records, even though the timestamps I give to this
routine should give me all the records that are in the data base. The
type of that column on this table is of course also a timestamp.
What am I doing wrong here, or is it a bug in Derby?
Thanks a lot in advance for helpful replies
Malte Kempff