mybatis + DB2数据库常见报错:jdbc type 0 not yet supported
来源:互联网 发布:iphone刷机后数据恢复 编辑:程序博客网 时间:2024/06/06 21:03
mybatis + DB2数据库常见报错:jdbc type 0 not yet supported。
最近做项目,我也遇到了这个问题,并且多次遇到了,有时候改改这里,动动那里,问题也解决了,
但是不搞清楚这个问题的根本原因,还是不放心。我的情况是这样的:进行一个数据库查询操作,会向后台
传递一个参数,SQL大致是这样的:
SELECT
PRODUCT_NAME, PRODUCT_COLOR
FROM
PRODUCT
WHERE
PRODUCT_NAME = #PRODUCT_NAME#
在前台,我们需要把PRODUCT_NAME的值传递给数据库,但是也可能会出现不传值的情况。
思考一个问题:下面的2个查询语句,执行时,会报错吗?为什么?
SELECT * FROM TABLENAME WHERE NAME = '';
SELECT * FROM TABLENAME WHERE NAME = NULL;
互联网上,关于这个问题,最多的文章,下面这个帖子,内容大致如下:
Hey all,y/nnnnnnnnnyy
I would like to share you guys this problem im getting constantly by using
Ibatis via jdbc to do queries on DB2...
Let's say we have written a simple query like this
SELECT
PCT_SCO_MAX,
FROM
FLES_PERC_SCO
WHERE
COD_COMPANY = #codCompany# AND
COD_SELLER = #codSeller#
the JDBC drivers via Ibatis framework CANNOT map a EMPTY STRING value into
"codSeller". infact it maps "null" as you can see in the log:
DEBUG [java.sql.PreparedStatement]--<{pstm-105524} Parameters: [112, null]>
but this way makes your query NOT fetch any results...
So i've rounded the problem witha /dynamic TAG but this solution is not
stylish ;
<isNotEmpty prepend="AND" property="codSeller">
COD_SELLER = #codTipoUnita#
</isNotEmpty>
<isEmpty prepend="AND" property="codSeller">
COD_SELLER = ''
</isEmpty>
someone got a better idea???
通过上面的方式,是可以解决这个报错问题的。笔者在实际项目中进行过测试。这里整理一下,mark一下,
下次再遇到这种报错,就能快速定位问题。
0 0
- mybatis + DB2数据库常见报错:jdbc type 0 not yet supported
- DB2数据库连接(jdbc连接)encoding not supported
- 建联合主键报错DB2 Database Error: ERROR [42997] [IBM][DB2/AIX64] SQL0270N Function not supported (Reason c
- 建联合主键报错DB2 Database Error: ERROR [42997] [IBM][DB2/AIX64] SQL0270N Function not supported (Reason c
- Oracle APEX 报错List of Values not supported for this type
- Spring MVC报错"Content type 'application/x-www-form-urlencoded' not supported"怎么解决
- jdbc 连接db2数据库报错 SQLSTATE=08001
- mybatis 报错: Caused by: org.apache.ibatis.type.TypeException: JDBC requires that the Jdbc
- 报错:nested transactions not supported
- tflearn安装报错scipy not supported!
- win10 运行LoadRunner报错“Error (-81024): LR_VUG: The 'QTWeb' type is not supported on 'WIN32' platforms”
- 启动oracle11g数据库报memory_target not supported on this system错解决方案
- 启动oracle11g数据库报memory_target not supported on this system错解决方案
- oracle数据库开启报MEMORY_TARGET not supported on this system错
- 使用JDBC连接DB2时encoding not supported异常的解决方法
- mybatis报错Type interface xxx.Dao is not known to the MapperRegistry
- mybatis-plugin is not activated yet解决办法
- spring+mybatis 报Could not load driverClass ${jdbc.driverClass}
- EngineerCMS优化算法从2.71s到38ms
- c++ 简单多线程实例
- Leetcode 207. Course Schedule 210. Course Schedule II
- RabbitMQ Server 环境配置中的一些坑
- 使用Parity建立Proof-of-Authority (PoA) Ethereum Chain5分钟快速从无到有建立Ethereum联盟链
- mybatis + DB2数据库常见报错:jdbc type 0 not yet supported
- FPGA 延时和 吞吐率 Latency versus Throughput
- 【Hibernate】hql小结
- POJ 1573 Robot Motion (模拟)
- POJ 2376 Cleaning Shifts 区间贪心
- 自定义圆形头像CirclemageView
- 定义栈的数据结构,请在该类型中实现一个能够得到栈最小元素的min函数。时间复杂度都是O(1)
- 抛开 React 学习 React(2)
- 如何查看新买手机是否翻新机?