• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

two select statements  RSS feed

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Marshal
Posts: 38659
676
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mary,
You can use another set of connection/statement objects.
 
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!