java.sql.SQLException: '@P0' 附近有语法错误
2011-12-21 17:21
471 查看
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
相关文章推荐
- [Exception JavaWeb 1] - Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P2' 附近有语法错误。
- java.sql.SQLException: '@P0' 附近有语法错误
- java.sql.SQLException: '@P0' 附近有语法错误
- "java.sql.SQLException:@P0" 附近有错误
- '@P0' 附近有语法错误
- MySql系列:中文写入数据库出现错误java.sql.SQLException: Incorrect string value: '\xE5\xxxx' for column 'xxxx' at row 1及其解决方法
- 在关键字'('附近有语法错误 Incorrect syntax near '(' in sql server table values function
- jeesite导入数据库错误:java.sql.SQLException: Incorrect string value: '\xE4\xB8\xAD\xE5\x9B\xBD' for column 'name' at row 1问题解决
- javax.transaction.xa.XAException: java.sql.SQLException: 无法创建 XA 控制连接。错误: 未能找到存储过程 'master..xp_sqljdbc_xa_init'
- .ner core InvalidOperationException: Cannot find compilation library location for package 'xxx' 和 SqlException: 'OFFSET' 附近有语法错误。 在 FETCH 语句中选项 NEXT 的用法无效。问题
- java.sql.SQLException: 批处理中出现错误: batch must be either executed or cleared
- java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)错误原因
- Cause:java.sql.SQLException:Incorrect string value:'\xF0\x9F\x99\x86\xF0\x9f...'
- java.sql.SQLException: ORA-00600: 内部错误代码,参数: [ttcgcshnd-1], [0], [], [], [], [], [], []
- resultset 对象获取行字段数据时报:java.sql.SQLException: Column 'id' not found.
- java使用Sqlite 出现类似java.sql.SQLException: no such table: employee错误
- Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
- Java错误提示-------java.sql.SQLException:ResultSet is closed
- mysql插入中文数据报错 java.sql.SQLException: Incorrect string value: '\xE5\x90\x88\xE8\xAE\xA1' for column
- 08:49:45,218 WARN JDBCExceptionReporter:71 - SQL Error: 156, SQLState: S1000 关键字 'user' 附近有语法错误。