From b10cebd692b610a13ea27b6150a79726de59f40e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 25 Apr 2015 20:51:38 +1200 Subject: Implement async position update --- src/org/traccar/database/DataManager.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/org/traccar/database/DataManager.java') diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 2f029e74c..faded815b 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -362,6 +362,31 @@ public class DataManager { } } + public List getDeviceList(long userId) throws SQLException { + + Connection connection = dataSource.getConnection(); + try { + PreparedStatement statement = connection.prepareStatement( + "SELECT id FROM device WHERE id IN (" + + "SELECT device_id FROM user_device WHERE user_id = ?);"); + try { + statement.setLong(1, userId); + + ResultSet resultSet = statement.executeQuery(); + + List result = new LinkedList(); + while (resultSet.next()) { + result.add(resultSet.getLong(1)); + } + return result; + } finally { + statement.close(); + } + } finally { + connection.close(); + } + } + public JsonArray getDevices(long userId) throws SQLException { Connection connection = dataSource.getConnection(); -- cgit v1.2.3