• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PreparedStatement Change

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to convert this dyanamic query into a preparedStatement to fetch data from a table in an efficent way.The query has 4 attributes which are required to be displayed according to the user input and even if the user enters only one input it should return all the other attributes.





Some one please help me with this,I am not able to make the query in the if statement as prepared statement.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
vijay, please CarefullyChooseOneForum. I've removed the identical threads you started in Java in General and Performance.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijay,

You mean to say con.prepareStatement(YOUR QUERY) doesnt work?
 
vijay umar
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry for multiple post Darryl.

Hello Rav,the first query using select is appended at every if condition used,So i just need to make those query=query+..... statements as prepared statements.
 
vijay umar
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
People,do you need more clarity on this?
 
rav pad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijay,
I understood your requirement. This is query is used for a search page where the results are displayed based on the conditions selected.
1) Do you want to pass on the paramters to the statement during run time like we do for prepared statements?
2) If yes for above question then how do you intend to construct the query?
3) Why do you want to use preparedstatements?

 
Ranch Hand
Posts: 277
Oracle Spring Flex
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijay,

I don't understand. What your problem with this. from your code, i find that, you are not binding the values to the query, you append it to query. Then you can simply use Statement instead of prepared statement
 
reply
    Bookmark Topic Watch Topic
  • New Topic