### Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
### The error may exist in com/shboka/gos/mapper/BaseinfoMapper.xml
### The error may involve com.shboka.gos.mapper.BaseinfoMapper.getGoods-Inline
### The error occurred while setting parameters
### SQL: select top ? * from base_goodsinfo where (goodsid not in (select top (?*?) goodsid from base_goodsinfo order by goodsid)) order by goodsid
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
; bad SQL grammar []; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
### The error may exist in com/shboka/gos/mapper/BaseinfoMapper.xml
### The error may involve com.shboka.gos.mapper.BaseinfoMapper.getGoods-Inline
### The error occurred while setting parameters
### SQL: select top ? * from base_goodsinfo where (goodsid not in (select top (?*?) goodsid from base_goodsinfo order by goodsid)) order by goodsid
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
; bad SQL grammar []; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
### The error may exist in com/shboka/gos/mapper/BaseinfoMapper.xml
### The error may involve com.shboka.gos.mapper.BaseinfoMapper.getGoods-Inline
### The error occurred while setting parameters
### SQL: select top ? * from base_goodsinfo where (goodsid not in (select top (?*?) goodsid from base_goodsinfo order by goodsid)) order by goodsid
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
; bad SQL grammar []; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
### The error may exist in com/shboka/gos/mapper/BaseinfoMapper.xml
### The error may involve com.shboka.gos.mapper.BaseinfoMapper.getGoods-Inline
### The error occurred while setting parameters
### SQL: select top ? * from base_goodsinfo where (goodsid not in (select top (?*?) goodsid from base_goodsinfo order by goodsid)) order by goodsid
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
; bad SQL grammar []; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近有语法错误。
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:98)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
我的SQL语句
SELECT TOP #{pageSize} *
FROM BASE_GOODSINFO
WHERE (GOODSID NOT IN
(SELECT TOP (#{pageSize}*#{page}) GOODSID
FROM BASE_GOODSINFO
ORDER BY GOODSID))
ORDER BY GOODSID
解决方法:select top ${pageSize}....
将#改成$就Ok了.