JDBC Template querying

I am trying to execute this method using jdbc template:

 public String getClientName(String uuid) {
    System.out.println("UUID here in the dao layer is: " + uuid);
    String sql = "Select email from client where uuid=?";

    return jdbcTemplate.query(sql, new ResultSetExtractor<String>() {

        @Override
        public String extractData(ResultSet rs) throws SQLException,        DataAccessException {
            return rs.getString("email");
        }
    });
}

However I am getting this error:

SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [Select email from client where uuid=?]; nested exception is org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying =?
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

Where am I going wrong?

Jon Skeet
people
quotationmark

You're not using your uuid parameter anywhere... I suspect you actually want:

return jdbcTemplate.query(sql, new Object[] { uuid },
    new ResultSetExtractor<String>() { ... });

That way uuid will be used as the value for the parameter in your SQL.

people

See more on this question at Stackoverflow