mybatis异常 bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorE

这个错误是自己开发过程中不细心导致的,特记下来,作为警惕。

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ''1'' at line 14

mysql分页 limit中需要整数,结果自己 dao层写成了String 类型,(低级错误)

<select id="queryPastLimit" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from  hui_app_lottery_past 
where lotterytype = #{lotterytype} 
<if test="issuenumber != null and '' !=issuenumber">
<![CDATA[ and issuenumber < #{issuenumber} ]]>
</if>
order by issuenumber desc limit #{pageSize}

</select>

dao层: public List<LotteryPast> queryPastLimit(@Param("issuenumber")String issuenumber,@Param("lotterytype")String lotterytype,@Param("pageSize") String pageSize);

正确写法为 :public List<LotteryPast> queryPastLimit(@Param("issuenumber")String issuenumber,@Param("lotterytype")String lotterytype,@Param("pageSize") int pageSize);

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

mybatis异常 bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorE

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭