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(); } }
public static void deleteMailById(Message message) { // precondition blablabla String sql = "DELETE FROM mail WHERE mailid = " + message.getId() + ";"; try { getStatement().execute(sql); getStatement().close(); } catch (SQLException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } }