Hi,
In my application I have a search page in which the user can enter various search criteria. For example on one of the search pages there are 5 input fields. 2 of them are date fields one is numeric and the 2 are text fields. The user can enter search values in any of the fields. assuming the entered value is valid, I create a select statement. Now if I use the Statement class to search the database creating the
string is easy. But I am trying to figure out an elegant way to do the same for PreparedStatement. Before I go into why I feel Statment is easier than PreparedStatement I just want you to know that the reason I want to use PreparedStatement is because from what I have understood, it will give me a better performance. If it is not so in this situation, please let me know.
Now, my case!:
Say the user enters 'Frank', 123 & 3/3/2003 as the 3 things he wants to search on, then using Statment I can easily do this using a logic as follows. (for now lets ignore the logic for anding of the various criterias)
And that's it if I Use Statment. If I were to use PreparedStatment I would have to do something like the following
I don't think this is a good solution, and I am open to comments and suggestions. Hope to hear your opinions soon.
Thanks.
- Poorav