Check: *ResultSetMetaData rsmd = rs.*getMetaData() rsmd.*getColumnCount*() // to get the maximum index worth to check.
And just like said Pankaj Jain - if you know how the students table looks like you shall create the POJO class responsible for storaging the one Student data for that. It will also be easier to control/manage the db table's data type (getting all values as String will make your life harder in Java soon or later (lots of unnecessery conversions)). And will be very ok for aggregate generic control (List<Student> differs from List<Object>) Regards, 2012/8/27 Joseph John <jjk.s...@gmail.com> > I am trying out this options now > lsm.add(rs.getString(1) + ","+ rs.getString(2)+ "," + rs.getString(3) + > "," + rs.getString(4)+ "," + rs.getString(5)); > > > On Monday, August 27, 2012 4:02:26 PM UTC+4, Joseph John wrote: >> >> Hi All >> I am a novice, just trying out >> I am trying to read all the values of the table to an array >> I am using the code >> " Statement stat = (Statement) conn.createStatement(); >> String SQLstring = "select * from students "; >> ResultSet rs = (ResultSet) stat.executeQuery(SQLstring); >> List lsm = new ArrayList(); >> while (rs.next()) { >> >> lsm.add(rs.getString(1)); >> >> This way, I get only the first field value in my ArrayList "lsm", how >> could I add the other values such as rs.getString(2), rs.getString(3) to >> my arrayList 'lsm >> Guidance requested >> Thanks >> Joseph John >> >> -- > You received this message because you are subscribed to the Google Groups > "JPassion.com: Web Programming Basics" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/jpassion_web/-/aF-zd6iJRd0J. > > To post to this group, send email to jpassion_web@googlegroups.com. > To unsubscribe from this group, send email to > jpassion_web+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/jpassion_web?hl=en. > -- You received this message because you are subscribed to the Google Groups "JPassion.com: Web Programming Basics" group. To post to this group, send email to jpassion_web@googlegroups.com. To unsubscribe from this group, send email to jpassion_web+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jpassion_web?hl=en.