0
This query normally functions in postgresql:
select nome as "pessoas?" from pessoa
But in java I did a dao which has a method called find:
sql = "select nome as 'teste?' from pessoa where id=?";
Gives the message:
ERROR: syntax error at or near "'test?'"
PS.: I am using Preparedstatement.
@Override
    public Pessoa enncontrarAlias(int id) {
    Pessoa pessoa = null;
    sql = "select nome as \"teste?\" from pessoa where id=?";
    try {
        pst = conexao.prepareStatement(sql);
        pst.setInt(1, id);
        rs = pst.executeQuery();
        while(rs.next()){
            pessoa = new Pessoa();
            pessoa.setNome(rs.getString("nome"));
        }
        rs.close();
        return pessoa;
    } catch (SQLException e) {
         throw new RuntimeException(e);     }   
}
						
What is "test?"? What do you want with this question? Preparedstatement is understanding this as if it were a parameter.
– user28595
'test? ' is the name of the alias, I don’t know could be 'names? '. But you need to have the question I’m doing a test here...
– Aline
You can add how you are declaring and executing the query by Preparedstatement?
– user28595
@Diegof is there, I edited it. Look.
– Aline
Still making a mistake?
– user28595
When you remove the
?works?– rray
Yes. even if it makes a mistake
– Aline
Which version of postgres is using?
– rray