标签:object stack dbr trace int 常用 column etl while
import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class ListResult { private List<Map<String, Object>> dbRestlt; public ListResult(ResultSet rs) { setDBRestlt(rs); } private void setDBRestlt(ResultSet rs) { try { if (rs == null) { return; } ResultSetMetaData md = rs.getMetaData(); int num = md.getColumnCount(); dbRestlt = new ArrayList<>(); while (rs.next()) { Map<String, Object> mapOfColValues = new HashMap<>(num); for (int i = 1; i <= num; i++) { mapOfColValues.put(md.getColumnName(i), rs.getObject(i)); } dbRestlt.add(mapOfColValues); } rs.close(); } catch (SQLException e) { e.printStackTrace(); } } public List<Map<String, Object>> getListRestlt() { return dbRestlt; } }
标签:object stack dbr trace int 常用 column etl while
原文地址:http://www.cnblogs.com/swtjavaspace/p/6703988.html