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> 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 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> getListRestlt() {
return dbRestlt;
}
}