File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Servlets - dynamic query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Servlets - dynamic query" Watch "Servlets - dynamic query" New topic
Author

Servlets - dynamic query

swati maken
Greenhorn

Joined: Jan 12, 2001
Posts: 14
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

Joined: Jan 23, 2001
Posts: 46
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


Sun Certified Programmer for Java2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets - dynamic query
 
Similar Threads
Paging search results and multiple browser windows
How to convert blob data to image and display
display a dynamic search page
How to make pagination?
memory usage with EntityBeans