daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest May 16th, 2018 105 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. private void updateHitCounter() {
  2.         Connection connection = getConnection();
  3.         try {
  4.             String sql = "UPDATE hits SET counter = counter + 1";
  5.             PreparedStatement stmt = connection.prepareStatement(sql);
  6.             stmt.executeUpdate();
  7.         } catch (SQLException e) {
  8.             e.printStackTrace();
  9.         } finally {
  10.             closeConnection(connection);
  11.         }
  12.     }
  13.  
  14.     private void getHitCounterImage(HttpServletRequest req,
  15.                                     HttpServletResponse res)
  16.             throws IOException {
  17.         Connection connection = getConnection();
  18.         String hits = "";
  19.         try {
  20.             String sql = "SELECT counter FROM hits";
  21.             PreparedStatement stmt = connection.prepareStatement(sql);
  22.             ResultSet rs = stmt.executeQuery();
  23.             while (rs.next()) {
  24.                 hits = rs.getString("counter");
  25.             }
  26.            
  27.         } catch (SQLException e) {
  28.             e.printStackTrace();
  29.         } finally {
  30.             closeConnection(connection);
  31.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top