Converting ResultSet into ArrayList
public ArrayList resultSetToArrayList(ResultSet rs) throws SQLException{
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
ArrayList results = new ArrayList();
while (rs.next()){
HashMap row = new HashMap();
results.add(row);
for(int i=1; i<=columns; i++){
row.put(md.getColumnName(i),rs.getObject(i));
}
}
return results;
}
No comments:
Post a Comment