List
PreparedStatement ps = null;
ResultSet rs = null;
String query = "select dep_id,dep_name from department";
try{
ps = (PreparedStatement) con.prepareStatement(query);
rs = ps.executeQuery();
while(rs.next()){
Department d = new Department();
d.setDepId(rs.getInt(1));
d.setDepName(rs.getString(2));
list.add(d);
}
}catch(Exception e){
e.printStackTrace();
}
return list;
}
No comments:
Post a Comment