From c1fcf803adfe06a0a54b3e51c4fd2d67e6b732d8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 24 Jun 2016 16:13:46 +0300 Subject: fix uid queries --- src/main/java/com/juick/server/UserQueries.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java index c9f804cf..817ae5d3 100644 --- a/src/main/java/com/juick/server/UserQueries.java +++ b/src/main/java/com/juick/server/UserQueries.java @@ -171,11 +171,19 @@ public class UserQueries { } public static int getUIDbyName(JdbcTemplate sql, String uname) { - return sql.queryForObject("SELECT id FROM users WHERE nick=?", Integer.class, uname); + try { + return sql.queryForObject("SELECT id FROM users WHERE nick=?", Integer.class, uname); + } catch (EmptyResultDataAccessException e) { + return 0; + } } public static int getUIDbyHash(JdbcTemplate sql, String hash) { - return sql.queryForObject("SELECT user_id FROM logins WHERE hash=?", Integer.class, hash); + try { + return sql.queryForObject("SELECT user_id FROM logins WHERE hash=?", Integer.class, hash); + } catch (EmptyResultDataAccessException e) { + return 0; + } } public static com.juick.User getUserByHash(JdbcTemplate sql, String hash) { -- cgit v1.2.3