初学JDBC,调用PreparedStatement对象的executeUpdate方法,提示 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 '%''',请求前辈支援。以下为代码 private static int UpdateScore(Object... params) throws Exception { int result = 0;
String sql = "UPDATE student SET score=? WHERE sex=? and NAME LIKE ''?%'';";
Connection connection = JDBCUtil.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(sql);
preparedStatement.setInt(1, Integer.parseInt(params[0].toString()));
preparedStatement.setString(2, params[1].toString());
preparedStatement.setString(3, params[2].toString());
result = preparedStatement.executeUpdate(); return result;
}
添加回答
举报
0/150
提交
取消