Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets - dynamic query

 
swati maken
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
My problem is that if I want to create a dynamic query, in which I am successfull also, and I want to put this query in if -- else loop so how can it be possible.
Actually I have to do the search and show the result to the user which matches his or her search criteria and the result is to be fetched from the database. So I am creating the query dynamically and I have stored this query in a string now I want to put this query in if then else loop and fetch the records based on the query . But how this is possible I don't know.
Please help me out.
Waiting for ur reply.
Thanks.
Swati
 
Arunagiri, Shanmugham
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try this out. Could be of some help..
int i=0;
rs=statement.executeQuery(<your query String here > );
while(rs.next())
{
++i;
if(i==0)
out.println("Your criteria does not match ");
else
out.println(rs.getString(1));
}
I hope u r expecting something like this..
Arun
SCJP

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic