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 57 58 59
| public void insertBoard(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 = "insert into itwill_board value(" +"?,?,?,?,?," +"?,?,?,?,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, 0); pstmt.setInt(7, num); pstmt.setInt(8, 0); pstmt.setInt(9, 0); pstmt.setString(10, bb.getFile()); pstmt.setString(11, bb.getIp());
pstmt.executeUpdate(); System.out.println("게시판글쓰기 성공"); } catch (Exception e) { System.out.println("게시판글쓰기 실패"); e.printStackTrace(); } finally { closeDB(); } }
|