为了账号安全,请及时绑定邮箱和手机立即绑定

JDBC中调用PreparedStatement的用法报错

JDBC中调用PreparedStatement的用法报错

忽然笑 2018-08-06 14:17:05
初学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;     }
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 1846 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信