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
| public int insertBoard(BoardDTO bdto){ int result = 0; int bno = 0;
try { getCon(); sql = "select max(bno) from itwill_board"; pstmt = con.prepareStatement(sql); rs = pstmt.executeQuery(); if(rs.next()){ bno = rs.getInt(1)+1; } System.out.println("DAO : 글번호 "+bno); sql ="insert into itwill_board(bno,name,passwd,subject,content," + "readcount,re_ref,re_lev,re_seq,date,file,ip) " + "values(?,?,?,?,?," + "?,?,?,?,now()," + "?,?)"; pstmt = con.prepareStatement(sql); pstmt.setInt(1, bno); pstmt.setString(2, bdto.getName()); pstmt.setString(3, bdto.getPw()); pstmt.setString(4, bdto.getSubject()); pstmt.setString(5, bdto.getContent()); pstmt.setInt(6, 0); pstmt.setInt(7, bno); pstmt.setInt(8, 0); pstmt.setInt(9, 0); pstmt.setString(10, bdto.getIp()); pstmt.setString(11, bdto.getFile()); result = pstmt.executeUpdate(); System.out.println("DAO : 글쓰기 완료! "); } catch (Exception e) { e.printStackTrace(); } finally { closeDB(); } return result; }
|