java - How to convert ResultSet into Object[] and retrieve the data -


i have list<object[]> records=null;

i retrieving data , storing in resultset.

now, how convert resultset object[] , return records(retrieved values).

for whatever weird reasons need this. here how:

list<object[]> records=new arraylist<object[]>(); while(resultset.next()){     int cols = resultset.getmetadata().getcolumncount();     object[] arr = new object[cols];     for(int i=0; i<cols; i++){       arr[i] = resultset.getobject(i+1);     }     records.add(arr); } 

my 2 cents:

ideally, have proper object maps table columns java object fields. instead of using array of objects, set properties pojo or value object (vo) , return list of object. simpler , makes more sense. may want revisit design if have live on list of object array!


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -