Spring JDBC를 이용하여 실습 진행 할 예정이므로 소스코드를 직접 사용하진 않아도 됨
public List<GuestBookVO> getGuestBookList(){
List<GuestBookVO> list = new ArrayList<>();
GuestBookVO vo = null;
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try{
conn = DBUtil.getConnection();
String sql = "select * from guestbook";
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
vo = new GuestBookVO();
vo.setNo(rs.getInt(1));
vo.setId(rs.getString(2));
vo.setTitle(rs.getString(3));
vo.setConetnt(rs.getString(4));
vo.setRegDate(rs.getString(5));
list.add(vo);
}
}catch(Exception e){
e.printStackTrace();
}finally {
DBUtil.close(conn, ps, rs);
}
return list;
}