diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/juick/server/UserQueries.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java index af7997ea..068f0c4b 100644 --- a/src/main/java/com/juick/server/UserQueries.java +++ b/src/main/java/com/juick/server/UserQueries.java @@ -92,10 +92,13 @@ public class UserQueries { return uid; } - public static User getUserByUID(JdbcTemplate sql, int uid) { - return sql.queryForObject("SELECT id, nick,banned FROM users WHERE id=?", - new Object[] {uid}, - new UserMapper()); + public static Optional<User> getUserByUID(JdbcTemplate sql, int uid) { + try { + return Optional.of(sql.queryForObject("SELECT id, nick,banned FROM users WHERE id=?", + new UserMapper(), uid)); + } catch (EmptyResultDataAccessException e) { + return Optional.empty(); + } } public static User getUserByName(JdbcTemplate sql, String username) { |