I have the query like : select domain,hits from temp order by domain desc limit 10 offset 0; now running through JDBC and prepared statement my query converted to:
String prepareselectSQL="select domain,hits from temp order by ? ? limit ? offset ?;";
PreparedStatement preparedStatement = null;
preparedStatement = connection.prepareStatement(prepareselectSQL);
preparedStatement.setString(1, "domain");
preparedStatement.setString(2, "desc");
preparedStatement.setInt(3, 10);
preparedStatement.setInt(4, 0);
ResultSet rs = preparedStatement.executeQuery();
now above code gives me an error :
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
please help on this,how will i use consecutive question mark in preparestatement.