解决使用sap数据库驱动查询hana数据库时,like '%param%' 失效问题

在使用SAP HANA数据库时,遇到使用LIKE '%param%'进行模糊查询失败的问题,原因是HANA的CONCAT函数仅支持两个参数。通过查阅官方文档,了解到CONCAT函数的用法,并调整查询语句,从而解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


开始使用mysql驱动访问数据库时我们正常的模糊查询写法是

concat('%',#{contractId,jdbcType=VARCHAR},'%')

但是hana语法中concat方法是只有两个参数的,因此会报出

### Cause: java.sql.SQLException: A problem occurred while trying to acquire a cached PreparedStatement in a background thread.
; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; A problem occurred while trying to acquire a cached PreparedStatement in a background thread.; nested exception is java.sql.SQLException: A problem occurred while trying to acquire a cached PreparedStatement in a background thread.] with root cause

com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [316]: wrong number of arguments in function invocation: line 8 col 28 (at pos 346)
	at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.createException(SQLExceptionSapDB.java:334)
	at com.sap.db.jdbc.exceptions.SQLExceptionSapDB.generateDatabaseException(SQLExceptionS
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值