【发布时间】:2020-04-29 12:10:18
【问题描述】:
我尝试使用preparedStatement 向表中插入一个新值,但我得到一个我无法解决的语法错误。
Java 代码:
String sql2 = "INSERT INTO Repondre VALUES ( ?, ?, ?, ?)";
preparedStatement = connection.prepareStatement(sql2);
preparedStatement.setInt(1, 1);
preparedStatement.setInt(2, 1);
preparedStatement.setInt(3,resultSet.getInt(1));
RadioButton rb = (RadioButton)q1.getSelectedToggle();
preparedStatement.setString(4,rb.getText().toLowerCase());
preparedStatement.executeUpdate(sql2);
错误代码:
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?, ?, ?, ?)' at line 1
希望你能帮我谢谢。
【问题讨论】: