一、问题

因为需要在数据库保存pdf的解析文件,需要用大的数据类型保存数据内容,所以需要使用CLOB数据文件类型;

  • 二、方法

数据库使用CLOB类型的数据,使用方法和其他的一样,是Character Large Object 的缩写;在使用Mybatis框架的时候,jdbcType可以写CLOB,也可以写String;即

insert into student valuse {
	#{id,jdbcType = VARCHAR},
	#{name,jdbcType = VARCHAR},
	#{article,jdbcType = CLOB}
}

或者:

insert into student valuse {
#{id,jdbcType = VARCHAR},
#{name,jdbcType = VARCHAR},
#{article,jdbcType = VARCHAR}
}

VARCHAR/Varchar2:采用单字节存储,有两个最大长度:一个是在字段类型4000;
Blob 采用单字节存储,适合保存二进制数据,如图片文件。
Clob 采用多字节存储,适合保存大型文本等字符类型数据。

三、疑问

这里,我遇到了一个问题,刚开始写的时候,我在Mybatis中配置数据库类型的时候,配置错了,数据库表中字段是CLOB类型,但是写mybatis的的jdbcType是VARCHAR类型,但是数据库也没有报错;我们查看官网的资料,
在这里插入图片描述

插入的时候也能正常插入,我怀疑是没有达到4000字节,没有报错,其也能存入,望大神赐教;

GitHub 加速计划 / js / json
18
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:3 个月前 )
f06604fc * :page_facing_up: bump the copyright years Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :page_facing_up: bump the copyright years Signed-off-by: Niels Lohmann <mail@nlohmann.me> * :page_facing_up: bump the copyright years Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me> Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com> 16 小时前
d23291ba * add a ci step for Json_Diagnostic_Positions Signed-off-by: Harinath Nampally <harinath922@gmail.com> * Update ci.cmake to address review comments Signed-off-by: Harinath Nampally <harinath922@gmail.com> * address review comment Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix typo in the comment Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix typos in ci.cmake Signed-off-by: Harinath Nampally <harinath922@gmail.com> * invoke the new ci step from ubuntu.yml Signed-off-by: Harinath Nampally <harinath922@gmail.com> * issue4561 - use diagnostic positions for exceptions Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix ci_test_documentation check Signed-off-by: Harinath Nampally <harinath922@gmail.com> * address review comments Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix ci check failures for unit-diagnostic-postions.cpp Signed-off-by: Harinath Nampally <harinath922@gmail.com> * improvements based on review comments Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix const correctness string Signed-off-by: Harinath Nampally <harinath922@gmail.com> * further refinements based on reviews Signed-off-by: Harinath Nampally <harinath922@gmail.com> * add one more test case for full coverage Signed-off-by: Harinath Nampally <harinath922@gmail.com> * ci check fix - add const Signed-off-by: Harinath Nampally <harinath922@gmail.com> * add unit tests for json_diagnostic_postions only Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix ci_test_diagnostics Signed-off-by: Harinath Nampally <harinath922@gmail.com> * fix ci_test_build_documentation check Signed-off-by: Harinath Nampally <harinath922@gmail.com> --------- Signed-off-by: Harinath Nampally <harinath922@gmail.com> 23 小时前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐