aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-24 16:13:46 +0300
committerGravatar Vitaly Takmazov2016-06-24 16:13:46 +0300
commitc1fcf803adfe06a0a54b3e51c4fd2d67e6b732d8 (patch)
tree5ed4404055bec62d6cfd2dff9bcdc2a9edeb8ef1 /src
parent1ce6bc55817129159b1cda5076d039e9c3bc8508 (diff)
fix uid queries
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/server/UserQueries.java12
1 files 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) {