Alguém poderia me mostrar onde está o erro?
public void buscaPergunta(int id) {
Perguntas p1 = new Perguntas();
try {
String sql = "Select Perguntas from Questoes where idQuestoes =?";
PreparedStatement stmt;
stmt = conexao.prepareStatement(sql);
stmt.setInt(1, id);
ResultSet rs;
rs = stmt.executeQuery(sql);
while (rs.next()) {
p1.setPergunta(rs.getString("Perguntas"));
JOptionPane.showMessageDialog(null,p1.getPergunta());
}
stmt.close();
rs.close();
} catch (SQLException ex) {
//ex.printStackTrace();
JOptionPane.showMessageDialog(null,ex);
}
}
O erro que aparece:
"you have an error in your SQL syntax;check the manual that corresponds to your MYSQL server version for the rigth syntax to use near '?' at line 1.