解决使用sap数据库驱动查询hana数据库时,like '%param%' 失效问题
2017-11-07 18:32
1986 查看
开始使用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(SQLExceptionSapDB.java:174)
at com.sap.db.jdbc.packet.ReplyPacket.buildExceptionChain(ReplyPacket.java:100)
at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:1141)
at com.sap.db.jdbc.CallableStatementSapDB.sendCommand(CallableStatementSapDB.java:1964)
不知道的就会一直检查自己的程序,最后我也是查看了hana官方的文档后才清楚!!!
CONCAT
语法:
CONCAT (str1, str2)
描述:
返回位于 s
tr1 后
的 s
tr2 联
合组成的字符串。级联操作符(
||)与
该函数作用相同。 这是hana官方文档的原话!
所以我们调整下查询语句就可以解决了
LIKE concat('%',#{contId,jdbcType=VARCHAR}) || '%'
非常感谢项目组的老大哥给的文档,很好用!可以在博客一下载
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(SQLExceptionSapDB.java:174)
at com.sap.db.jdbc.packet.ReplyPacket.buildExceptionChain(ReplyPacket.java:100)
at com.sap.db.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:1141)
at com.sap.db.jdbc.CallableStatementSapDB.sendCommand(CallableStatementSapDB.java:1964)
不知道的就会一直检查自己的程序,最后我也是查看了hana官方的文档后才清楚!!!
CONCAT
语法:
CONCAT (str1, str2)
描述:
返回位于 s
tr1 后
的 s
tr2 联
合组成的字符串。级联操作符(
||)与
该函数作用相同。 这是hana官方文档的原话!
所以我们调整下查询语句就可以解决了
LIKE concat('%',#{contId,jdbcType=VARCHAR}) || '%'
非常感谢项目组的老大哥给的文档,很好用!可以在博客一下载
相关文章推荐
- 解决使用cmd或powershell进行数据库(MySQL,SQLite3...)查询时中文乱码的问题
- 解决node.js中使用for循环查询数据库异步执行的问题
- 解决"操作必须使用一个可更新的查询"问题
- SQL中使用LIKE查询注意的问题
- 如何在Ruby On Rails中使用Unicode(解决数据库中文化的问题)
- 关于ASP.NET“操作必须使用一个可更新的查询”问题的解决方法
- 如何解决ADO.NET访问Access数据库出现"操作必须使用一个可更新的查询"的问题
- SQL Server 数据库突然不能使用解决问题回顾
- 执行SQL语句时出现问题操作必须使用一个可更新的查询错误的解决方法
- 解决Weblogic 配置连接池加载数据库驱动失败问题
- 求助Hibernate问题(我使用Criteria 查询数据库表时,当客户端调用到第3次就出现问题 )
- 使用MyEclipse 6.0连接SQL 2000和2005数据库(JDBC) 遇到的问题,急需解决
- 解决使用ASP无法连接 ORACLE 9i 数据库的问题。
- 解决了使用Firefox登录网通上网记录查询网页的问题
- Hibernate3的Like用法,解决中文查询问题
- 第一次使用jdbc连接postgre数据库碰到的问题及解决方法
- "执行SQL语句时出现问题操作必须使用一个可更新的查询"错误的解决方法
- Hibernate3的Like用法,解决中文查询问题
- 解决使用ASP无法连接 ORACLE 9i 数据库的问题。
- Hibernate使用property-ref属性解决遗留数据库One To Many关系的问题。