Reputation: 49537
I have a login arraylist
where i have stored users loginid using following mysql query
Code:
query = "select LoginID from issuedeposit id where id.DueDate < CURDATE()";
result = statement.executeQuery(query);
while(result.next())
{
String loginid = result.getString(1);
loginarray.add(loginid);
}
now I want to use the loginid values stored in the above arraylist
to fetch users emailid form other
table. I am using following query
Code:
for(int i=0;i<=loginarray.size();i++)
{
res = statement1.executeQuery("select EmailID form studentaccount sa where sa.LoginID = '"+ loginarray.get(i) +"' ");
String email = res.getString(1);
emailarray.add(email);
}
but am getting error in the above query. So have i correctly used the for loop
or it should be used inside the query...?
I am using JDBC and MySql
Upvotes: 1
Views: 2481
Reputation: 76537
res = statement1.executeQuery("select EmailID form studentaccount sa
where sa.LoginID = '"+ loginarray.get(i) +"' ");
Should be
res = statement1.executeQuery("select EmailID FROM studentaccount sa
where sa.LoginID = '"+ loginarray.get(i) +"' ");
Upvotes: 2