I have this code that converts a JDBC result set into a list of hash tables:
private static ArrayList<HashMap<String, Object>> convertResultSet(ResultSet resultSet) throws SQLException {
ArrayList<HashMap<String, Object>> map = new ArrayList<HashMap<String, Object>>();
ResultSetMetaData rsmd = resultSet.getMetaData();
int nColumns = rsmd.getColumnCount();
while(resultSet.next()) {
HashMap<String, Object> hash = new HashMap<String, Object>();
for (int i = 0; i < nColumns; i++)
{
hash.put(rsmd.getColumnName(i), resultSet.getObject(i));
}
map.add(hash);
}
return map;
}
but when run, it throws a "Column index out of range." exception.
Any ideas?