Olá
estou com a seguinte consulta dentro do meu código
String sql = "Select * from " + this.table + " where ( login = ? OR nome = ? ) ";
if (excetoSelecionado) {
sql += " AND login != ? ";
}
sql += " limit 0,1 ";
ps = con.prepareStatement(sql);
ps.setString(1, usuario.getLogin());
ps.setString(2, usuario.getNome());
if (excetoSelecionado) {
ps.setString(3, usuario.getLogin());
}
System.out.println(ps.toString());
O valor que ela retorna está correto e validado, testei varias vezes, como estou sem prática alguma no últimos 5 anos na linguagem, talvez seja alguma peculiaridade do PreparedStatement, alguèm poderia me ajudar com isto?
O erro que retorna é este
GRAVE: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) WHERE login=‘login1’’ at line 1