public static int delete(long id, long version) throws SQLException { PreparedStatement ps = DbRegistry.getDbConnection().prepareStatement(DELETE); ps.setLong(1, id); ps.setLong(2, version); int count = ps.executeUpdate(); ps.close(); return count; }
public static int update(long groupid, long userid, long id, long version) throws SQLException { PreparedStatement ps = DbRegistry.getDbConnection().prepareStatement(UPDATE); ps.setLong(1, groupid); ps.setLong(2, userid); ps.setLong(3, id); ps.setLong(4, version); int count = ps.executeUpdate(); ps.close(); return count; }
public static int insert(long userid, long groupid) throws SQLException { PreparedStatement ps = DbRegistry.getDbConnection().prepareStatement(INSERT); ps.setInt(1, 1); // version always inserted @ 1 ps.setLong(2, userid); ps.setLong(3, groupid); int count = ps.executeUpdate(); ps.close(); return count; }
@Override protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { setupRequest(request); try { // Do Stuff List<IPlayer> players = PlayerInputMapper.findAll(); request.setAttribute("players", players); // Commit DbRegistry.getDbConnection().commit(); // Forward to a jsp, make sure you fill it in properly request.getRequestDispatcher("/WEB-INF/jsp/xml/players.jsp").forward(request, response); } catch (Exception e) { forwardError(request, response, e.getMessage()); e.printStackTrace(); } finally { teardownRequest(); } }
public static void dropTable() throws SQLException { SQLLogger.processUpdate(DbRegistry.getDbConnection().createStatement(), DROP_SQL); }