From 4683d6b828d2bf6d56a53205c785f7982ce1be11 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 27 Jun 2016 13:29:51 +0300 Subject: fixes --- .../java/com/juick/server/MessagesQueries.java | 22 +++++++++++++--------- src/main/java/com/juick/server/UserQueries.java | 12 ++++++++---- 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'src/main/java/com/juick') diff --git a/src/main/java/com/juick/server/MessagesQueries.java b/src/main/java/com/juick/server/MessagesQueries.java index bfd0d71a..77998d16 100644 --- a/src/main/java/com/juick/server/MessagesQueries.java +++ b/src/main/java/com/juick/server/MessagesQueries.java @@ -268,15 +268,19 @@ public class MessagesQueries { } public static User getMessageAuthor(JdbcTemplate sql, int mid) { - return sql.queryForObject("SELECT messages.user_id,users.nick " - + "FROM messages INNER JOIN users " - + "ON messages.user_id=users.id WHERE messages.message_id=?", - new Object[]{mid}, (rs, num) -> { - User res = new com.juick.User(); - res.setUID(rs.getInt(1)); - res.setUName(rs.getString(2)); - return res; - }); + try { + return sql.queryForObject("SELECT messages.user_id,users.nick " + + "FROM messages INNER JOIN users " + + "ON messages.user_id=users.id WHERE messages.message_id=?", + new Object[]{mid}, (rs, num) -> { + User res = new com.juick.User(); + res.setUID(rs.getInt(1)); + res.setUName(rs.getString(2)); + return res; + }); + } catch (EmptyResultDataAccessException e) { + return null; + } } public static List getMessageTags(JdbcTemplate sql, int mid) { diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java index e7aee0f5..f071de39 100644 --- a/src/main/java/com/juick/server/UserQueries.java +++ b/src/main/java/com/juick/server/UserQueries.java @@ -100,8 +100,8 @@ public class UserQueries { public static User getUserByName(JdbcTemplate sql, String username) { try { return sql.queryForObject("SELECT id,nick,banned FROM users WHERE nick=?", - new Object[]{username}, - new UserMapper()); + new UserMapper(), + username); } catch (EmptyResultDataAccessException e) { return null; } @@ -259,8 +259,12 @@ public class UserQueries { } public static boolean isInWL(JdbcTemplate sql, int uid, int check) { - return sql.queryForObject("SELECT 1 FROM wl_users WHERE user_id=? AND wl_user_id=?", - new Object[] {uid, check}, Integer.class) == 1; + try { + return sql.queryForObject("SELECT 1 FROM wl_users WHERE user_id=? AND wl_user_id=?", + Integer.class, uid, check) == 1; + } catch (EmptyResultDataAccessException e) { + return false; + } } public static boolean isInBL(JdbcTemplate sql, int uid, int check) { -- cgit v1.2.3