Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void updateHitCounter() {
- Connection connection = getConnection();
- try {
- String sql = "UPDATE hits SET counter = counter + 1";
- PreparedStatement stmt = connection.prepareStatement(sql);
- stmt.executeUpdate();
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- closeConnection(connection);
- }
- }
- private void getHitCounterImage(HttpServletRequest req,
- HttpServletResponse res)
- throws IOException {
- Connection connection = getConnection();
- String hits = "";
- try {
- String sql = "SELECT counter FROM hits";
- PreparedStatement stmt = connection.prepareStatement(sql);
- ResultSet rs = stmt.executeQuery();
- while (rs.next()) {
- hits = rs.getString("counter");
- }
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- closeConnection(connection);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement