I have dropdown menu that has list of column names from certain table in the database and I have textbox where user can type what one is looking for. User first selects the column from dropdown menu and types on textbox what s/he is looking for. I am kind of lost how can i match those dropdown column name and textbox string to look under specific column in oracle database.. Any sample code or suggestion would be helpful.. Thank you
String colname = request.getParameter("colname");//get the column name from teh dropdown
String value = request.getParameter("value");//get the value that the user entered
PreparedStatement searchQuery = null;
String searchString = String.format("Select * from yourtable where %s = ?", colname);
//create a connection , say con
searchQuery = con.prepareStatement(searchString);
searchQuery.setString(1, value);
ReultSet rs = searchQuery.executeQuery();
This solution is only basic a idea so you have to modify to suit. If the columns that you are searching are of different types then you have to cater for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With