• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PreparedStatement Change

 
vijay umar
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • 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.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vijay, please CarefullyChooseOneForum. I've removed the identical threads you started in Java in General and Performance.
 
rav pad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
People,do you need more clarity on this?
 
rav pad
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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?

 
Ashwin Sridhar
Ranch Hand
Posts: 277
Flex Oracle Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic