xt4k

Untitled

Apr 27th, 2021
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. @Step("SQL: Convert ResultSet:`{0}` to List<HashMap<String, String>> form and return as list (atomic).")
  2. private static List<HashMap<String, String>> lGetListOfDataFromResultSet(ResultSet rs) throws SQLException {
  3. ResultSetMetaData rsmd = rs.getMetaData();
  4. int count = rsmd.getColumnCount();
  5. String[] colNames = new String[count];
  6. List<HashMap<String, String>> list = new ArrayList<>();
  7. while (rs.next()) {
  8. HashMap<String, String> map = new HashMap<>();
  9. for (int i = 1; i <= count; i++) {
  10. colNames[i - 1] = rsmd.getColumnLabel(i);
  11. map.put(colNames[i - 1], String.valueOf(rs.getObject(i)));
  12. }
  13. list.add(map);
  14. }
  15. return list;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment