java.sql.SQLException: '@P0' 附近有语法错误
2011-12-21 17:21
1481 查看
String sql = "select top ? * from bbs_posts where p_fid=? order by p_addtime desc";
预编译:
Exception:
java.sql.SQLException: '@P0' 附近有语法错误。
原因:sql不支持为select top ? 预编译,换成动态拼接.@P0指的是第一个参数附近有错误,要是在第二个参数(?)附近,则错误为'@P1' 附近有语法错误。
String sql = "select top %s * from bbs_posts where p_fid=? order by p_addtime desc";
sql = String.format(sql, num);
参考:http://www.blogjava.net/jzone/articles/305388.html
http://hi.baidu.com/wenli158/blog/item/6553123314d7f759ac4b5f35.html
预编译:
Exception:
java.sql.SQLException: '@P0' 附近有语法错误。
原因:sql不支持为select top ? 预编译,换成动态拼接.@P0指的是第一个参数附近有错误,要是在第二个参数(?)附近,则错误为'@P1' 附近有语法错误。
String sql = "select top %s * from bbs_posts where p_fid=? order by p_addtime desc";
sql = String.format(sql, num);
参考:http://www.blogjava.net/jzone/articles/305388.html
http://hi.baidu.com/wenli158/blog/item/6553123314d7f759ac4b5f35.html
相关文章推荐
- java.sql.SQLException: '@P0' 附近有语法错误
- java.sql.SQLException: '@P0' 附近有语法错误
- "java.sql.SQLException:@P0" 附近有错误
- [Exception JavaWeb 1] - Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P2' 附近有语法错误。
- com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
- mybatis 动态SQL '@P0' 附近有语法错误
- JSP com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
- ibatis Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误
- java.sql.SQLException: Generated keys not requested. You need to ... 错误
- 【问题解决】MyBatis分页查询SQL Server2008时出现'@P0' 附近有语法错误
- sql查询报java.sql.SQLException: Column 'LC_ID' not found 的错误实际上是mysql在hibernate别名的问题
- java.sql.SQLException: 批处理中出现错误: batch must be either executed or cleared
- 服务器错误:SQL Error: 102, SQLState: S0001, 'limit' 附近有语法错误 的解决办法
- javax.transaction.xa.XAException: java.sql.SQLException: 无法创建 XA 控制连接。错误: 未能找到存储过程 'master..xp_sqljdbc_xa_init'
- 未重新服务器而导致的错误java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)错误原因
- 归档日志满以后引起的错误 Caused by: java.sql.SQLException: ORA-00257:
- jtds错误:java.sql.SQLException: I/O Error: SSO Failed: Native SSPI library not loa
- Spring_错误 java.sql.SQLException: Lock wait timeout exceeded | CannotAcquireLockException 的解决
- 在关键字'('附近有语法错误 Incorrect syntax near '(' in sql server table values function