com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-418, SQLSTATE=42610, SQLERRMC=null

写了一条sql,在db2数据库中可以执行,但是转换成mybatis的mapper文件后,在执行排序操作时报该错误。

我排序是这样写的

<if test="orderStr != null">
ORDER BY #{orderStr}
</if>

看了一下其他地方的写法发现使用$,而不是#,改成如下就可以了

<if test="orderStr != null">
ORDER BY ${orderStr}
</if>

 

posted @ 2018-09-03 10:09  coffee9527  阅读(4559)  评论(0编辑  收藏  举报