A simple query, if there is Chinese in the parameters. As follows:
<select id="xxxx" resultType="hashmap"> select * from talbe_a a where a.kpeople = ${name} </select>
Error reporting:
org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-00904: "Xiao Yaxuan": Identifier is invalid ... Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "Xiao Yaxuan": Identifier is invalid ....
mybatis sql log
18:06:36,192 DEBUG JdbcTransaction:47 - Openning JDBC Connection 18:06:36,830 DEBUG PooledDataSource:47 - Created connection 1459361227. 18:06:36,843 DEBUG queryrealactormediatop:47 - ooo Using Connection [oracle.jdbc.driver.T4CConnection@56fc15cb] 18:06:36,843 DEBUG queryrealactormediatop:47 - ==> Preparing: select * from table_a a where v1.kpeople = 萧亚轩 18:06:36,961 DEBUG queryrealactormediatop:47 - ==> Parameters:
Note: “Xiao Yaxuan” has no single quotation marks around it, not “?” There is no value in the parameter list
The modification is actually very simple:
V1: change $to#
<select id="xxxx" resultType="hashmap"> select * from talbe_a a where a.kpeople = #{name} </select>
V2: Add ” single quotation mark
<select id="xxxx" resultType="hashmap"> select * from talbe_a a where a.kpeople = ‘${name}‘ </select>
#It’s just a string
$is not necessarily a string or other type
Similar Posts:
- [Solved] Mybatis Mapping Error: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘id’ in ‘class java.lang.String
- [Solved] json.decoder.JSONDecodeError: Expecting ‘,‘ delimiter: line xx column xx (char xxx)
- Hive Error: Error while compiling statement: FAILED: ParseException line 1:7 Failed to recognize
- [Solved] org.apache.ibatis.binding.BindingException: Parameter ‘area_id’ not found. Available parameters are [areaId, param1]
- Git commit -m ‘Add Readme’ error: pathspec ‘Readme” did not match any file(s) known to git
- [Solved] Java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
- How to Solve Python Syntax error: invalid character in identifier
- Zend Studio 9 configure and install Zend debugger
- Treatment of MySQL database keyword as column name by mybatisplus — sqlsyntax errorexception: you have an error in your SQL syntax;
- JAVA Error: too many characters in character literal