salim salim - 1 year ago 54
SQL Question

i want to search values from mysql data on java using search action performed but its giving me errors parameter index out of range

enter image description here

Search button is not working properly it says parameter index is out of range

Answer Source

A PreparedStatement may use placeholders ? , that enables you to pass values that will be escaped .

Your query has no placeholder, so calling a replacement method like :


throws an Exception, because there isn't a placeholder's of index 1 in your query.

If what you want, is to search for a particular Employee based on the values you have (name and surname), you may execute a parameterized query with two placeholders :

pstmt=conn.prepareStatement("select * from empdetails where EmployeeName = ? AND EmployeeSurname = ?");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download