Skip to content

Instantly share code, notes, and snippets.

View sahilpaudel's full-sized avatar
🏠
Working from home

Sahil Paudel sahilpaudel

🏠
Working from home
View GitHub Profile
@sahilpaudel
sahilpaudel / ResultSet to List
Created January 25, 2022 20:06 — forked from cworks/ResultSet to List
Java - Convert a ResultSet to a List of Maps, where each Map is a row of data
/**
* Convert the ResultSet to a List of Maps, where each Map represents a row with columnNames and columValues
* @param rs
* @return
* @throws SQLException
*/
private List<Map<String, Object>> resultSetToList(ResultSet rs) throws SQLException {
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();