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
| public void insertGoods(GoodsDTO gdto) { int num = 0; try{ getCon(); sql = "select max(gno) from itwill_goods"; pstmt = con.prepareStatement(sql); rs = pstmt.executeQuery(); if(rs.next()){ num = rs.getInt(1)+1; } System.out.println("DAO : 상품번호 "+num);
sql = "insert into itwill_goods values(?,?,?,?,?," + "?,?,?,?,?," + "now())"; pstmt = con.prepareStatement(sql); pstmt.setInt(1, num); pstmt.setString(2, gdto.getCategory()); pstmt.setString(3, gdto.getName()); pstmt.setInt(4, gdto.getPrice()); pstmt.setString(5, gdto.getColor()); pstmt.setInt(6, gdto.getAmount()); pstmt.setString(7, gdto.getSize()); pstmt.setString(8, gdto.getContent()); pstmt.setString(9, gdto.getImage()); pstmt.setInt(10, gdto.getBest()); pstmt.executeUpdate(); System.out.println("상품등록완료"); }catch(Exception e){ e.printStackTrace(); }finally{ closeDB(); } }
|