public List<HashMap<String,String>> thansResultSet2List() throws SQLException{
List<HashMap<String,String>> result=new ArrayList<HashMap<String,String>>();
int columnCount = md.getColumnCount(); //返回此 ResultSet 对象中的列数
try {
while(rs.next()){
map=new HashMap<String,String>(columnCount);
for(int i = 1; i <= columnCount; i++){
map.put(md.getColumnName(i), String.valueOf(rs.getObject(i)));
}
result.add(map);
}
System.out.println("result:"+result.toString());
return result;
} catch (SQLException e) {
addException(e, DatabaseException.RS_ROW_EXCEPTION);
return null;
}
}
List<HashMap<String,String>> result=new ArrayList<HashMap<String,String>>();
HashMap<String,String> map=new HashMap<String,String>();
if(rs==null)return null;
ResultSetMetaData md = rs.getMetaData(); //得到结果集(rs)的结构信息,比如字段数、字段名等int columnCount = md.getColumnCount(); //返回此 ResultSet 对象中的列数
try {
while(rs.next()){
map=new HashMap<String,String>(columnCount);
for(int i = 1; i <= columnCount; i++){
map.put(md.getColumnName(i), String.valueOf(rs.getObject(i)));
}
result.add(map);
}
System.out.println("result:"+result.toString());
return result;
} catch (SQLException e) {
addException(e, DatabaseException.RS_ROW_EXCEPTION);
return null;
}
}