Open GoogleCodeExporter opened 9 years ago
next() return false after update().
Original comment by eadress_...@yahoo.fr
on 20 Apr 2015 at 12:50
Until there is a solution, I fixed my code like this :
db.beginTransaction(SqlJetTransactionMode.WRITE);
try
{
// Get the unsent usages
ISqlJetTable usage = db.getTable(USAGE_TABLE);
ISqlJetCursor cursor = usage.open();
if (!cursor.eof())
{
do
{
// Fix a conflit between lookup() and update()
if (cursor.getInteger(SENT_INDEX) == 0)
{
// Try to send the usage event to the REST server
userId = cursor.getInteger(USER_ID_FIELD);
machineId = cursor.getInteger(MACHINE_ID_FIELD);
duration = cursor.getInteger(DURATION_FIELD);
date = cursor.getInteger(DATE_FIELD);
JSONObject response = rest.sendEvent(REST.CONSUM_EVENT, userId, machineId, duration, false, date);
// If it succeed
if (response != null)
{
// Update the usage sent state
cursor.update(
cursor.getValue(ID_FIELD),
userId,
machineId,
duration,
cursor.getValue(COST_FIELD),
date,
1
);
}
Thread.sleep(500);
}
}
while (cursor.next());
}
cursor.close();
}
catch (InterruptedException e)
{
ErrorHandler.log(e);
}
finally
{
db.commit();
}
Original comment by eadress_...@yahoo.fr
on 8 May 2015 at 8:28
Original issue reported on code.google.com by
eadress_...@yahoo.fr
on 20 Apr 2015 at 12:43