How to convert a ResultSet to a hashtable?

Well, that should be easy, but I can't find a solution anywhere. And I'm still not comfortable using Java to figure out how to do this.

Until now, I could go through ResultSet, and I am already proud of myself.

I need a list so that I can just skip it and then call something like myRow.get('ColumnName');.

In addition, there MIGHT is a different data type instead of Hashtablestoring the key / value. Any tips?

Many thanks!

+2
source share
2 answers

myRow.get('ColumnName'); ResultSet, . getObject (String columnLabel). ResultSet Map , a ResultSet () . , ResultSet.next(), " " . : ReusltSet , .

List<Map<String, Object>>, List, Map, Map<String /*columnName*/, Integer /*Index*/> . , , .

+4

HashMap. Hashtable - ...

:

HashMap<String, Object> p = new HashMap<String, Object>();
p.put("ResultSetkey1","ResultSetvalue1");
p.put("ResultSetkey2","ResultSetvalue2");
+1

All Articles