1.通过jdbc方式存储clob类型数据
private void updateJdbcStudById(SqlMapClient sqlmap, Map inmap){ String infos = (String)inmap.get("infos"); //字符串类型的clob类型 Reader reader = new StringReader(infos); try { Connection conn = sqlmap.getDataSource().getConnection(); String sql = "update student set informations = ? where stuno = ?"; PreparedStatement ps = conn.prepareStatement(sql); //为clob类型赋值 ps.setCharacterStream(1, reader, infos.length()); ps.setString(2, (String)inmap.get("stuno")); ps.execute(); ps.close(); conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
2.通过ibatis存取clob类型数据
informations字段配置
private List<Student> queryStudentById(SqlMapClient sqlmap, String studno){ List<Student> lists = new ArrayList<Student>(); try { lists = sqlmap.queryForList("queryStdById", studno); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return lists; }
配置文件如下
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"> <sqlMap> <!-- 指定映射,查询clob类型需要指定 --> <resultMap class="com.dto.Student" id="stumap"> <result property="stuno" column="STUNO"/> <result property="stuname" column="STUNAME"/> <result property="stuaddress" column="STUADDRESS"/> <result property="sex" column="SEX"/> <result property="notes" column="NOTES"/> <result property="informations" column="INFORMATIONS" javaType="String" jdbcType="CLOB"/> </resultMap> <!-- 查询学生信息 --> <select id="queryStdById" parameterClass="string" resultMap="stumap"> select stuno,stuname,stuaddress,sex,notes,informations from student where stuno = #stuno# </select> <update id="updatestdById" parameterClass="java.util.HashMap"> update student set informations = #infos,javaType=String,jdbcType=CLOB# where stuno = #stuno# </update> </sqlMap>
附相关的驱动包
相关推荐
ibatis 读取oracle clob类型
整合了springmvc,hibernate,ibatis,jdbc等技术的强大框架,写的非常全面,谢谢老邵的成果。
NULL 博文链接:https://bijian1013.iteye.com/blog/2233121
iBATIS基于JDBC的半自动化持久层框架.ppt
大家都要用到IBATIS框架时,连接到MYECLIPSE驱动JAR包
ibatis中输入输出各种类型的参数分析及#与$区别
NULL 博文链接:https://huibin.iteye.com/blog/804070
包含了ibatis及jdbc的驱动,需要的可以下载
ibatis3.0中in的用法ibatis3.0中in的用法ibatis3.0中in的用法ibatis3.0中in的用法
实现ibatis对数据的连接,增查删改。.xml文件对sql语句的映射。基本知识基本全部覆盖
ibatis 数据缓存,帮你了解ibatis的数据缓存机制。
Ibatis 数据层 轻型框架 Ibatis 数据层 轻型框架 Ibatis 数据层 轻型框架 Ibatis 数据层 轻型框架 Ibatis 数据层 轻型框架
iBatis操作MySQL增删改查,亲测可用,附带sql文件,完全配置,增加记录,删除指定记录以及全部记录,查询全部记录以及指定记录,更新记录等操作
ibatis学习 ibatis总结 ibatis ibatis ibatis
ibatis自定义数据类型在不支持中文的数据库存储汉字
NULL 博文链接:https://fuchao01.iteye.com/blog/551438
ibatis资料ibatis资料ibatis资料ibatis资料ibatis资料ibatis资料ibatis资料ibatis资料ibatis资料
ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南ibatis2指南
最后,还讨论了iBATIS的优缺点,及为什么是这样的一种方式,即所谓的“在完全OR与JDBC之间的一个幽雅的折衷。” <br>就象Developer's Notebook 系列中所有的书一样,你将由直接的且实用的方式获得信息,这些信息...
介绍Ibatis框架中需要同时连接多个资料库的方法,包括.net和Java两种