如何使用iBatis从数据库中选择BLOB列 [英] How to Select a BLOB column from database using iBatis

查看:259
本文介绍了如何使用iBatis从数据库中选择BLOB列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表的列之一是BLOB数据类型(Oracle 10g).我们有一个通过iBatis执行的简单选择查询,以选择BLOB列并使用Struts2& amp;显示它. JSP.

One of a table's column is of BLOB datatype (Oracle 10g). We have a simple select query executed via iBatis to select the BLOB column and display it using Struts2 & JSP.

iBatis xml文件中的结果标签的jdbctype为java.sql.Blob

The result tag in the iBatis xml file had the jdbctype as java.sql.Blob

<result property="uploadContent" column="uploadcontent" jdbctype="Blob"/>   

我们应该为Blob列提到任何typeHandler类吗? 当前,我们收到错误消息,指出列类型不匹配.

Should we be mentioning any typeHandler class for Blob column ? Currently we are getting an error stating column type mismatch.

注意:已选择此列并将其映射到属性类型为java.sql.Blob的java bean

Note: This column is selected and mapped into a java bean who has an attribute of type java.sql.Blob

推荐答案

我认为您不能在带有iBatis的Oracle中将本机jdbctype用于LOB类型.解决方案是创建自定义typeHandler来处理LOB,然后将其映射为-

I think you cannot use native jdbctype for LOB types in Oracle with iBatis. The solution is to create custom typeHandler to handle LOB and then map it like -

<result property="aClassStringProperty" column="aClobColumn" typeHandler="com.path.to.my.ClobTypeHandler"/>

有关typeHandlerCallback的更多信息这里.

这篇关于如何使用iBatis从数据库中选择BLOB列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆