개발/WEB개발
JSP 조회수 기능 만들기
DoR@Hee
2019. 1. 31. 18:23
VIEW - board_list.jsp 와 동일
Command - x
Model
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public void Hit(String bId) { Connection con = null; PreparedStatement pstmt = null; try { String query = "update board set bHit = bHit + 1 where bId = ?"; Class.forName(driver); con=DriverManager.getConnection(url, user, password); pstmt = con.prepareStatement(query); pstmt.setInt(1, Integer.parseInt(bId)); pstmt.executeUpdate(); } catch(Exception e) { e.printStackTrace(); } finally { try { if(pstmt != null) pstmt.close(); if(con != null) con.close(); } catch(Exception e2) { e2.printStackTrace(); } } } | cs |