当前使用版本(必填,否则不予处理)
3.5.0
该问题是如何引起的?(确定最新版也有问题再提!!!)
使用 crud sample 改成 HANA 数据库配置并执行,出现错误
HANA CONCAT 函数只能支持两个参数,但是生成的 SQL 有三个参数 CONCAT('%',?,'%'),所以报错。 请参见:https://help.sap.com/viewer/7c78579ce9b14a669c1f3295b0d8ca16/Cloud/en-US/20dd51f775191014990682ac74bbefe8.html
重现步骤(如果有就写完整)
报错信息
[ERROR] testSqlCondition Time elapsed: 0.281 s <<< ERROR! org.springframework.jdbc.BadSqlGrammarException:
Error querying database. Cause: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [316]: wrong number of arguments in function invocation: line 3 col 19 (at pos 53)
The error may exist in com/baomidou/mybatisplus/samples/crud/mapper/User2Mapper.java (best guess)
The error may involve com.baomidou.mybatisplus.samples.crud.mapper.User2Mapper.selectList
The error occurred while executing a query
SQL: SELECT id,name,age FROM user2 WHERE name LIKE CONCAT('%',?,'%')
Cause: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [316]: wrong number of arguments in function invocation: line 3 col 19 (at pos 53)
; bad SQL grammar []; nested exception is com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [316]: wrong number of arguments in function invocation: line 3 col 19 (at pos 53) at com.baomidou.mybatisplus.samples.crud.CrudTest.testSqlCondition(CrudTest.java:225) Caused by: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [316]: wrong number of arguments in function invocation: line 3 col 19 (at pos 53) at com.baomidou.mybatisplus.samples.crud.CrudTest.testSqlCondition(CrudTest.java:225)
Comment From: wanjianmojun
sap的垃圾驱动,很多方法不支持,比如要支持Connection.prepareStatement()这个预处理,得在平台关闭Statement routing,然后就算关闭了,还不支持setString()方法,这不是扯嘛,啥也设置不了,感觉想要适配改动好大 SAP官方文档说了不支持各种值的设置方法: The PreparedStatement/CallableStatement methods are not supported for the following SAP HANA data types:
setString(), setNString(), setCharacterStream(), setNCharacterStream(), setAsciiStream(), setClob(), and setNClob() for BINARY, VARBINARY, BLOB, and BINTEXT parameters.
setBytes(), setBinaryStream(), and setBlob() for CHAR, VARCHAR, NCHAR, NVARCHAR, SHORTTEXT, ALPHANUM (SAP HANA Platform only), CLOB, NCLOB, TEXT, and BINTEXT parameters.
SAP官方文档原话: Reduces the number of round trips between the client and the SAP HANA server by not sending a Prepare request to the server when Connection.prepareStatement() or Connection.prepareCall() is invoked. Enabling this property helps improve performance for applications by reducing the number of client-server round-trips without changing application logic.
Statement routing must be disabled or you cannot use deferred prepares.
Comment From: superwangnan
请问这个问题是修好了吗? :)