ITeye博客

ResultSet转换为List的方法

hao861002 · 2009-04-11 20:39 · java软件 · Markdown

ResultSet转换为List的方法

private static List convertList(ResultSet rs) throws SQLException {

List list = new ArrayList();

ResultSetMetaData md = rs.getMetaData();

int columnCount = md.getColumnCount(); //Map rowData;

while (rs.next()) { //rowData = new HashMap(columnCount);

Map rowData = new HashMap();

for (int i = 1; i <= columnCount; i++) {

rowData.put(md.getColumnName(i), rs.getObject(i));

}

 list.add(rowData);

} return list;

}

评论(1)

  1. #1 楼 · qintengfei · 2012-04-14 13:43

    不错,问题解决了。

评论功能维护中,当前仅展示历史评论。