Its very simple
create the object of ResultSetMetaData
and use the method getColumnCount()
cc columncount
while (rs.next()) {
for(int i=1; i<cc; i++)
lsm.add(rs.getString(i));
}
Sridhar Kokkula
Jyotsna Computer Technologies
Vadodara, Gujarat . Mobile : +91 9924421149
--- On Mon, 8/27/12, Pankaj Jain <[email protected]> wrote:
From: Pankaj Jain <[email protected]>
Subject: Re: [jpassion_web] Re: Want to store all the filed value of the
database table to a Array
To: [email protected]
Cc: [email protected]
Date: Monday, August 27, 2012, 6:01 PM
Hello Joseph
The better option is, create a POJO class with all the fields of database that
you want, create getters and setters of the fields and make a List of this
class. This way it will be easy to manage the data.
Thanks
Pankaj Jain
On Mon, Aug 27, 2012 at 5:48 PM, Joseph John <[email protected]> wrote:
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jpassion_web?hl=en.