aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DataManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database/DataManager.java')
-rw-r--r--src/org/traccar/database/DataManager.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 602345df9..2c78a53c4 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -267,4 +267,25 @@ public class DataManager {
}
}
+ public long login(String name, String password) throws SQLException {
+
+ Connection connection = dataSource.getConnection();
+ try {
+ PreparedStatement statement = connection.prepareStatement(
+ "SELECT id FROM users WHERE name = ? AND password = ?;");
+ try {
+ statement.setString(1, name);
+ statement.setString(2, password);
+
+ ResultSet result = statement.executeQuery();
+ result.next();
+ return result.getLong("id");
+ } finally {
+ statement.close();
+ }
+ } finally {
+ connection.close();
+ }
+ }
+
}