29DAY / JSP , JAVA / DTO, DAO insertform ,list
입력폼과 리스트처리 _DAO
public ArrayList<Member> mAllSelect() throws ClassNotFoundException, SQLException{
DriverDB db = new DriverDB();
conn = db.driverDbcon();
ArrayList<Member> alm = new ArrayList<Member>();
pstmt = conn.prepareStatement("select * from tb_member");
rs = pstmt.executeQuery();
while(rs.next()){
Member m = new Member();
m.setM_id(rs.getString("m_id"));
m.setM_pw(rs.getString("m_pw"));
m.setM_level(rs.getString("m_level"));
m.setM_name(rs.getString("m_name"));
m.setM_email(rs.getString("m_email"));
System.out.println(m);
alm.add(m);
}
pstmt.close();
conn.close();
rs.close();
return alm;
}
ArrayList를 쓰는이유?
<%
Mdao dao = new Mdao();
ArrayList<Member> get_alm = dao.mAllSelect();
for(int i=0;i<get_alm.size();i++){
Member m = get_alm.get(i);
%>
<tr>
<td><%=m.getM_id()%></td>
<td><%=m.getM_pw()%></td>
<td><%=m.getM_level()%></td>
<td><%=m.getM_name()%></td>
<td><%=m.getM_email()%></td>
<td>
</tr>
<%}%>