public static void saveMail(User user, Message message) { ResultSet resultSet = null; try { String sql = "INSERT INTO mail (mailid,userid,hash,message) values(" + message.getId() + "," + user.getId() + ",'" + message.getHash() + "','" + message.getContent() + "');"; getStatement().execute(sql); resultSet.close(); getStatement().close(); } catch (SQLException e) { e.printStackTrace(); } }
@Deprecated public static void addNewMessageToUser(User user, Message message) { String sql = "SELECT MAX(mailid) as 'maxid' FROM mail;"; ResultSet resultSet = null; int number = 10000; try { resultSet = getStatement().executeQuery(sql); resultSet.next(); number = resultSet.getInt("maxid"); number++; sql = "INSERT INTO mail (mailid,userid,hash,message) values(" + number + "," + user.getId() + ",'" + message.getHash() + "','" + message.getContent().replace("'", "\"") + "');"; getStatement().execute(sql); resultSet.close(); getStatement().close(); } catch (SQLException e) { e.printStackTrace(); } }