From 8161004d43dbd25ef78ea90c85ed20522008db05 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 18 Jan 2013 20:50:06 +1300 Subject: Enable progress hack --- .../traccar/protocol/ProgressProtocolDecoder.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java index d3f582225..43fce472c 100644 --- a/src/org/traccar/protocol/ProgressProtocolDecoder.java +++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java @@ -68,14 +68,16 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { private void loadLastIndex() { try { Properties p = getServerManager().getProperties(); - AdvancedConnection connection = new AdvancedConnection( - p.getProperty("database.url"), p.getProperty("database.user"), p.getProperty("database.password")); - NamedParameterStatement queryLastIndex = new NamedParameterStatement(connection, p.getProperty("database.selectLastIndex")); - queryLastIndex.prepare(); - queryLastIndex.setLong("device_id", deviceId); - ResultSet result = queryLastIndex.executeQuery(); - if (result.next()) { - lastIndex = result.getLong(1); + if (p.contains("database.selectLastIndex")) { + AdvancedConnection connection = new AdvancedConnection( + p.getProperty("database.url"), p.getProperty("database.user"), p.getProperty("database.password")); + NamedParameterStatement queryLastIndex = new NamedParameterStatement(connection, p.getProperty("database.selectLastIndex")); + queryLastIndex.prepare(); + queryLastIndex.setLong("device_id", deviceId); + ResultSet result = queryLastIndex.executeQuery(); + if (result.next()) { + lastIndex = result.getLong(1); + } } } catch(Exception error) { } @@ -120,7 +122,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { String imei = buf.readBytes(length).toString(Charset.defaultCharset()); try { deviceId = getDataManager().getDeviceByImei(imei).getId(); - //loadLastIndex(); + loadLastIndex(); } catch(Exception error) { Log.warning("Unknown device - " + imei + " (id - " + id + ")"); } -- cgit v1.2.3