I have table employee
I retrieve the columns as select emp_name,emp_add from employee
while(iResultSet1.next())
{
List expRptColWise = new ArrayList();
for(Integer i=1;i<=iResultSet1.getMetaData().getColumnCount();i++){
expRptColWise.add(iResultSet1.getString(i));
}
expRptRowWise.add(expRptColWise);
With the above snippet ,I get
emp_name | emp_add |
A | add1 |
B | add2 |
I want to add Serial No. coloumn in resultset so that I get result as
emp_name | emp_add |Sr_No|
A | add1 |1 |
B | add2 |2 |
Please guide me how to add column dynamically in resultset or collection object ,Here I have used ArrayList.
Set a Counter in the While Loop which you increments each time and use it in the output: