ResultSet values to store in arraylist
hello all,
Need help.Please help me in adding all the values from result set to the arraylist.
And also tell me as to how we comparing two string values with delimiter in it.For example :string1 = "Ejb,Jsp,Weblogic9.0,hibernate,jsf"
and string2 = "Weblogic9.0,struts"
in this two string at least one word of two string are matching so i will get the database values.
help me how to do this
[426 byte] By [
java@mania] at [2007-11-27 10:46:41]

# 1
> Need help.Please help me in adding all the values
> from result set to the arraylist.
What's the exact question? Tell us where you stucks while writing code. This is really straightforward.
> And also tell me as to how we comparing two string
> values with delimiter in it.For example :string1 =
> "Ejb,Jsp,Weblogic9.0,hibernate,jsf"
> and string2 = "Weblogic9.0,struts"
Read the String API [1]. It provides several useful methods, like indexOf(), contains(), matches(), split(), etcetera.
[1] http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
# 2
this i smy code for the arraylist
stmt=con.createStatement();
String query = "select a1,a2,a3 from usernametable";
rset = stmt.executeQuery(querya);
while(rset.next())
{
record = new ArrayList();
Object value = rset.getString("a1");
record.add(value);
Object value = rset.getString("a2");
record.add(value);
}
return record;
}
but this is not taking the value.
where am i going wrong.
# 4
The "querya" is not definied and you're overwriting the record with a new arraylist on every loop.
You should map ResultSet to List<RowObject>, where the RowObject is just a DTO (a simple class with private fields and public accessors, which can be used to transfer the data from layer to layer), which represents one database row.
# 6
hi BalusC ,
Sorry for writing ur wrong name in my previous reply.
Can u send simple example or a tutorial site for using the string methods. For using the split(), matches(), contains(). That i would help me for my work .
Mani