Has nothing to do with the iLIKE operator - identifiers cannot be parameterized. You need to decide on a different way to get the column "name" into the query string safely.
------------this one not working.
String ilikequerywithparameter = "SELECT * FROM emp" + " where name iLIKE '%"+"?"+"%' ";
PreparedStatement ilikestatementpara = Main.connection.prepareStatement(ilikequerywithparameter); ilikestatementpara.setString(1,"c"); ResultSet resultSet = ilikestatementpara.executeQuery();
The last code snippet have Exception error.Exception in thread "main" org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns:
You put the question mark inside single quotes in the submitted query and thus as far as the system is concerned it is just a string containing a question mark, not a parameter symbol. The direct way to make it work is to add string concatenation operators between the literal parts (which are quoted) and the parameter (which is not), having the server build the final string from the three individual parts.