aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-27 13:29:51 +0300
committerGravatar Vitaly Takmazov2016-06-27 13:29:51 +0300
commit4683d6b828d2bf6d56a53205c785f7982ce1be11 (patch)
treee795c09347edf170169df02fb579f416dcad0366 /src
parent6362eab34390b187944c7e3c12eb444e2fb2c455 (diff)
fixes
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/server/MessagesQueries.java22
-rw-r--r--src/main/java/com/juick/server/UserQueries.java12
2 files changed, 21 insertions, 13 deletions
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<com.juick.Tag> 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) {