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>
原文地址:https://www.cnblogs.com/coffee9527/p/9577103.html