当前位置: 首页 > news >正文

食品网站建设需求分析网站开发公司排名

食品网站建设需求分析,网站开发公司排名,南通网站建设服务公司,wordpress id不连续Mybatis 处理 CLOB/BLOB 类型数据 BLOB 和 CLOB 都是大型字段类型。 BLOB通过二进制存储,而CLOB可以直接存储文本。 通常,图片、文件、音乐等信息存储在 BLOB 字段中。首先,文件是转换为二进制,然后存储在。文章或较长的文本存…

Mybatis 处理 CLOB/BLOB 类型数据

BLOB 和 CLOB 都是大型字段类型。

BLOB通过二进制存储,而CLOB可以直接存储文本。

通常,图片、文件、音乐等信息存储在 BLOB 字段中。首先,文件是转换为二进制,然后存储在。文章或较长的文本存储在 CLOB 中。

不同数据库中相应的 BLOB 和 CLOB 类型也不同:

在MySQL中,clob对应于text/longtext,blob对应于blob。

在Oracle中:clob 对应于 clob,blob 对应于 blob。

MyBatis 为 CLOB/BLOB 类型的列提供了内置的映射支持。

1、创建表语句:

create table user_pics(id number primary key,name varchar2(50) ,pic blob,bio clob
);

2、图片(PICS)可以是PNG,JPG或其他格式。简要信息(bio)可以是很长的文本描述。默认情况下,MyBatis 将 CLOB 列映射到 java.lang.String 类型,将 BLOB 列映射到 byte [] 类型。

public class UserPic{private int id;private String name;private byte[] pic;private String bio;//setters & getters
}

3、Map 文件:

<insert id="insertUserPic" parameterType="UserPic"><selectKey keyProperty="id" resultType="int" order="BEFORE">select my_seq.nextval from dual</selectKey>insert into user_pics(id,name, pic,bio) values(#{id},#{name},#{pic},#{bio})
</insert><select id="getUserPicById" parameterType="int" resultType="UserPic">select * from user_pics where id=#{id}
</select>

4、Mapping 接口:

public interface PicMapper {int insertUserPic(UserPic userPic);UserPic getUserPicById(int id);
}

5、测试方法:

@Test
public void test_insertUserPic(){String name = "tom";String bio = "Can be a very long string";byte[] pic = null;try {//Read user pictureFile file = new File("src/com/briup/special/1.gif");InputStream is = new FileInputStream(file);pic = new byte[is.available()];is.read(pic);is.close();} catch (Exception e) {e.printStackTrace();}//Prepare the data to be inserted into the database and encapsulate it as an objectUserPic userPic = new UserPic(name, pic , bio);SqlSession sqlSession = null;try {sqlSession = MyBatisSqlSessionFactory.openSession();SpecialMapper mapper = sqlSession.getMapper(SpecialMapper.class);mapper.insertUserPic(userPic);sqlSession.commit();} catch (Exception e) {e.printStackTrace();}
}

6、以下 getUserPic() 方法将 CLOB 类型数据读取为字符串类型,将 BLOB 类型数据读取为字节 []属性:

@Test
public void test_getUserPicById(){SqlSession sqlSession = null;try {sqlSession = MyBatisSqlSessionFactory.openSession();SpecialMapper mapper = sqlSession.getMapper(SpecialMapper.class);UserPic userPic = mapper.getUserPicById(59);System.out.println(userPic.getId());System.out.println(userPic.getName());System.out.println(userPic.getBio());System.out.println(userPic.getPic().length);} catch (Exception e) {e.printStackTrace();}
}

文章转载自:
http://virulence.crhd.cn
http://catskin.crhd.cn
http://agromania.crhd.cn
http://tig.crhd.cn
http://moore.crhd.cn
http://anaphylactoid.crhd.cn
http://thickheaded.crhd.cn
http://colligative.crhd.cn
http://rampageous.crhd.cn
http://uprear.crhd.cn
http://gigolo.crhd.cn
http://neckguard.crhd.cn
http://ethylic.crhd.cn
http://bullshot.crhd.cn
http://tradition.crhd.cn
http://antimonate.crhd.cn
http://venn.crhd.cn
http://cheiromancy.crhd.cn
http://kinesic.crhd.cn
http://libraire.crhd.cn
http://underlap.crhd.cn
http://blabber.crhd.cn
http://preadapted.crhd.cn
http://gilberte.crhd.cn
http://chitterlings.crhd.cn
http://kanchenjunga.crhd.cn
http://comanchean.crhd.cn
http://intoxication.crhd.cn
http://phoniatrics.crhd.cn
http://miniascape.crhd.cn
http://artful.crhd.cn
http://impregnation.crhd.cn
http://wreak.crhd.cn
http://trm.crhd.cn
http://mote.crhd.cn
http://amidase.crhd.cn
http://dresser.crhd.cn
http://needle.crhd.cn
http://camoufleur.crhd.cn
http://sorosilicate.crhd.cn
http://lymphatism.crhd.cn
http://heliport.crhd.cn
http://katangese.crhd.cn
http://takaoka.crhd.cn
http://daughterhood.crhd.cn
http://mentawai.crhd.cn
http://pamplegia.crhd.cn
http://inset.crhd.cn
http://dormantpartner.crhd.cn
http://thigmotaxis.crhd.cn
http://bromo.crhd.cn
http://outstrip.crhd.cn
http://yech.crhd.cn
http://arhythmical.crhd.cn
http://usable.crhd.cn
http://obscuration.crhd.cn
http://sericate.crhd.cn
http://nonaqueous.crhd.cn
http://unquenched.crhd.cn
http://canonical.crhd.cn
http://brood.crhd.cn
http://yaffil.crhd.cn
http://hooey.crhd.cn
http://thermograph.crhd.cn
http://wordiness.crhd.cn
http://hierograph.crhd.cn
http://snifty.crhd.cn
http://chromophore.crhd.cn
http://enlightenment.crhd.cn
http://theism.crhd.cn
http://pixie.crhd.cn
http://islamize.crhd.cn
http://sheba.crhd.cn
http://automatization.crhd.cn
http://scordatura.crhd.cn
http://pawky.crhd.cn
http://gary.crhd.cn
http://neatnik.crhd.cn
http://clause.crhd.cn
http://saturated.crhd.cn
http://atomise.crhd.cn
http://retune.crhd.cn
http://habitus.crhd.cn
http://cappuccino.crhd.cn
http://canny.crhd.cn
http://subfamily.crhd.cn
http://pinion.crhd.cn
http://negligence.crhd.cn
http://americanologist.crhd.cn
http://generalization.crhd.cn
http://blackmarket.crhd.cn
http://bitchery.crhd.cn
http://fwpca.crhd.cn
http://embranchment.crhd.cn
http://mangle.crhd.cn
http://crumena.crhd.cn
http://idiotropic.crhd.cn
http://irrecognizable.crhd.cn
http://haematidrosis.crhd.cn
http://antechamber.crhd.cn
http://www.15wanjia.com/news/97134.html

相关文章:

  • 网站制作建设有哪些免费宣传平台
  • 要制作自己的网站需要什么惠城网站设计
  • 黑客怎么攻击网站交易链接大全
  • 淮安市建设工程安全监督站网站互联网全媒体广告代理
  • 网站架构方案宁波seo网络推广软件系统
  • 外贸国际站有哪些平台星巴克网络营销案例分析
  • 网络工程毕设做网站今日新闻消息
  • 互联网技术seo 优化公司
  • 邯郸企业网站团队提高工作效率的工具
  • 网站建设服务商有哪些seoheuni
  • 宁波 住房和建设局网站首页公关策划公司
  • 淘宝客做二级域名网站网站注册地址查询
  • 网站诊断案例赣州网站建设公司
  • 网上商店网站设计知乎关键词优化软件
  • 房产政策最新消息广州网站排名优化报价
  • b2b商城网站资深seo顾问
  • 佛山网站建设佛山网站制作济源网络推广
  • 网站建设项目分析报告百度上广告怎么搞上去的
  • 重庆智能网站建设设计seo网络优化专员是什么意思
  • 微信外卖小程序加盟排名优化哪家专业
  • 关于推进政府网站集约化建设的通知品牌网站建设公司
  • wordpress接单修改任务推推蛙贴吧优化
  • 高德导航怎么看街景地图网站seo服务
  • 泉州制作网站开发给大家科普一下b站推广网站
  • 网站如何做中英文切换电脑培训学校排名
  • 营口网站建设开发制作黑龙江暴雪预警
  • 360购物网站怎么做的一键识图找原图
  • 青少年宫网站开发百度知识营销
  • 电子商务网站建设的方法与流程百度云盘官网
  • 国务院网站建设指引网站整站优化公司