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
|
public void reInsertBoard(BoardDTO bdto) { int result =-1; 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, bdto.getRe_ref()); pstmt.setInt(2, bdto.getRe_seq()); pstmt.executeUpdate();
sql="insert into itwill_board " + "values(?,?,?,?,?" + ",?,?,?,?,now()" + ",?,?)"; pstmt = con.prepareStatement(sql); pstmt.setInt(1, num); pstmt.setString(2, bdto.getName()); pstmt.setString(3, bdto.getPw()); pstmt.setString(4, bdto.getSubject()); pstmt.setString(5, bdto.getContent()); pstmt.setInt(6, bdto.getReadcount()); pstmt.setInt(7, bdto.getRe_ref()); pstmt.setInt(8, bdto.getRe_lev()+1); pstmt.setInt(9, bdto.getRe_seq()+1); pstmt.setString(10, bdto.getFile()); pstmt.setString(11, bdto.getIp()); pstmt.executeUpdate(); System.out.println("답글쓰기 성공"); result = 1; } catch (Exception e) { e.printStackTrace(); } finally { closeDB(); } }
|