1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| public void reInsertBoard(BoardBean bb){ int num = 0; try { getCon(); sql = "select max(bno) from itwill_board"; pstmt = con.prepareStatement(sql); rs = pstmt.executeQuery(); if(rs.next()){ num = rs.getInt(1)+1; } System.out.println(" 답글 번호 : "+num); sql = "update itwill_board set re_seq=re_seq+1 " + "where re_ref=? and re_seq>?"; pstmt = con.prepareStatement(sql); pstmt.setInt(1, bb.getRe_ref()); pstmt.setInt(2, bb.getRe_seq()); pstmt.executeUpdate(); sql="insert into itwill_board " + "values(?,?,?,?,?" + ",?,?,?,?,now()" + ",?,?)"; pstmt = con.prepareStatement(sql); pstmt.setInt(1, num); pstmt.setString(2, bb.getName()); pstmt.setString(3, bb.getPw()); pstmt.setString(4, bb.getSubject()); pstmt.setString(5, bb.getContent()); pstmt.setInt(6, bb.getReadcount()); pstmt.setInt(7, bb.getRe_ref()); pstmt.setInt(8, bb.getRe_lev()+1); pstmt.setInt(9, bb.getRe_seq()+1); pstmt.setString(10, bb.getFile()); pstmt.setString(11, bb.getIp()); pstmt.executeUpdate(); System.out.println("답글쓰기 성공"); } catch (Exception e) { e.printStackTrace(); } finally { closeDB(); } }
|