| Author |
PreparedStatement Change
|
vijay umar
Ranch Hand
Joined: Mar 24, 2009
Posts: 100
|
|
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
Joined: May 03, 2008
Posts: 4167
|
|
|
vijay, please CarefullyChooseOneForum. I've removed the identical threads you started in Java in General and Performance.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
rav pad
Greenhorn
Joined: Jun 07, 2011
Posts: 3
|
|
Vijay,
You mean to say con.prepareStatement(YOUR QUERY) doesnt work?
|
 |
vijay umar
Ranch Hand
Joined: Mar 24, 2009
Posts: 100
|
|
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
Joined: Mar 24, 2009
Posts: 100
|
|
|
People,do you need more clarity on this?
|
 |
rav pad
Greenhorn
Joined: Jun 07, 2011
Posts: 3
|
|
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
Joined: Jul 09, 2011
Posts: 272
|
|
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
|
Ashwin Sridhar
SCJP | SCWCD | OCA
|
 |
 |
|
|
subject: PreparedStatement Change
|
|
|