diff options
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 25 |
1 files changed, 25 insertions, 0 deletions
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<Long> 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<Long> result = new LinkedList<Long>(); + 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(); |