String sql = "select top ? * from bbs_posts where p_fid=? order by p_addtime desc";


预编译:
Exception:

java.sql.SQLException: '@P0' 附近有语法错误java.sql.SQLException: '@P0' 附近有语法错误。


原因:sql不支持为select top ? 预编译,换成动态拼接.@P0指的是第一个参数附近有错误,要是在第二个参数(?)附近,则错误为'@P1' 附近有语法错误。

java.sql.SQLException: '@P0' 附近有语法错误String sql = "select top %s * from bbs_posts where p_fid=? order by p_addtime desc";
java.sql.SQLException: '@P0' 附近有语法错误        sql = String.format(sql, num);

参考:http://www.blogjava.net/jzone/articles/305388.html

http://hi.baidu.com/wenli158/blog/item/6553123314d7f759ac4b5f35.html

相关文章:

  • 2021-08-16
  • 2022-02-16
  • 2022-01-15
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-22
  • 2022-12-23
  • 2022-02-07
  • 2021-08-01
  • 2021-09-02
相关资源
相似解决方案