This query normally works in postgreSQL:
select nome as "pessoas?" from pessoa
But in java I made a dao that has a method called findAlias:
sql = "select nome as 'teste?' from pessoa where id=?";
Give the message:
ERROR: syntax error at or near "'test?'"
PS: I'm 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); }
}