aspose file tools
The moose likes JDBC and the fly likes two select statements Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "two select statements " Watch "two select statements " New topic
Author

two select statements

Mary Wallace
Ranch Hand

Joined: Aug 25, 2003
Posts: 138
In my jsp page i have to show around 20 question which I am taking from db.

For one of the question user need to select a state which again i have to

query the db. Since the frst query is already running i dont know how to
make the second select statement for the states?

Hope I am clear and thanks in advance.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26193
    
  66

Mary,
You can use another set of connection/statement objects.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

I prefer only to use a new statement - not a new connection.
But I'm not sure, whether a new connection has advantages.
I guess it will consume more time.

Another idea, (which might not fit) would be to get the possible states in the same first query (if there aren't too much) and cache them, and select the right one after the user made his decision.


http://home.arcor.de/hirnstrom/bewerbung
Gagan Gulati
Greenhorn

Joined: Jul 27, 2004
Posts: 7
Hey,

Are you getting all the 20 questions in one go ?
I mean, are you using the resultset to return you all 20 questions. You display them on the JSP and then the user picks up one of them ?
If that is the case, when the user picks up some other state, you can just fire another query using a Statement object.

-G
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: two select statements
 
Similar Threads
Extra rows when displaying resultSet in browser
Spring and Hibernate ... i am confuse
No results in query using JDBC, works in Db
how to load file into DB
Techniques for getting auto generated key for ms access?