大对象

Spring 数据库处理Clob/Blob大对象

旧巷老猫 提交于 2019-12-01 03:20:04
#概述 使用Spring的时候需求上难免说需要存储一下几种类型: 文本 图片 二进制 处理对象 Spring 支持通过 LobCreator/LobHandler 进行处理大对象 BLOB byte[] — getBlobAsBytes and setBlobAsBytes InputStream — getBlobAsBinaryStream and setBlobAsBinaryStream CLOB String — getClobAsString and setClobAsString InputStream — getClobAsAsciiStream and setClobAsAsciiStream Reader — getClobAsCharacterStream and setClobAsCharacterStream 入口 看到方法名就知道,在调用前会被执行一遍,刚好看看这个对象的实现,只有 AbstractLobCreatingPreparedStatementCallback ,接下来看看源码,看看有没有例子。 就是我想要的 使用例子 final File blobIn = new File("spring2004.jpg"); final InputStream blobIs = new FileInputStream(blobIn); final File