| Author |
passing the value obtained from DB
|
kenji kunoichi
Ranch Hand
Joined: Jun 02, 2007
Posts: 39
|
|
hi ,
I made a program which I first pull out values from database like this way :
public List getperInfoAll() {
int i = 0;
try
{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","root");
ps = con.createStatement();
rs = ps.executeQuery("select * from userx");
while(rs.next())
{
System.out.println(rs.getString(1));
perInfoAll.add(i,new perInfo(rs.getString(1),rs.getString(2),rs.getString(3)));
i++;
}
then in another funtion I want to use the value like :[/b]
public String sayHello() throws IOException,SQLException
{
getperInfoAll() ;
List abc = new ArrayList();
for(int i=0;i<2;i++)
{
abc.add(new Object[]{rs.getString(1),rs.getString(2),rs.getString(3)});
}
but I am getting an sqlexception...mainly because values are not going there... in abc.add so what error I am making? how to pass the ref there ?
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
|
getperInfoAll is returning a List, isn't it ? (I hope your closing everything properly before returning the list) Shouldn't you use this returned value somewhere ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
|
Please UseCodeTags.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Sherif Shehab
Ranch Hand
Joined: Mar 05, 2007
Posts: 472
|
|
|
Please can you put the sql exception ?
|
Thanks,
Sherif
|
 |
 |
|
|
subject: passing the value obtained from DB
|
|
|