链接如下:
<!-- ======== START OF CLASS DATA ======== -->
org.springframework.jdbc.support.lob
Class DefaultLobHandler
java.lang.Object
org.springframework.jdbc.support.lob.AbstractLobHandler
org.springframework.jdbc.support.lob.DefaultLobHandler
public class DefaultLobHandlerextends AbstractLobHandler
Default implementation of the LobHandler
interface. Invokes the direct accessor methods that java.sql.ResultSet
and java.sql.PreparedStatement
offer.
This LobHandler should work for any JDBC driver that is JDBC compliant in terms of the spec's suggestions regarding simple BLOB and CLOB handling. This does not apply to Oracle 9i, and only to a limited degree to Oracle 10g! As a consequence, use OracleLobHandler
for accessing Oracle BLOBs/CLOBs.
Some JDBC drivers require values with a BLOB/CLOB target column to be explicitly set through the JDBC setBlob
/ setClob
API: for example, PostgreSQL's driver. Switch the "wrapAsLob"
property to "true" when operating against such a driver.
On JDBC 4.0, this LobHandler also supports streaming the BLOB/CLOB content via the setBlob
/ setClob
variants that take a stream argument directly. Consider switching the "streamAsLob"
property to "true" when operating against a fully compliant JDBC 4.0 driver.
See the LobHandler
javadoc for a summary of recommendations.
setStreamAsLob(boolean)
, ResultSet.getBytes(int)
, ResultSet.getBinaryStream(int)
, ResultSet.getString(int)
, ResultSet.getAsciiStream(int)
, ResultSet.getCharacterStream(int)
, PreparedStatement.setBytes(int, byte[])
, PreparedStatement.setBinaryStream(int, java.io.InputStream, int)
, PreparedStatement.setString(int, java.lang.String)
, PreparedStatement.setAsciiStream(int, java.io.InputStream, int)
, PreparedStatement.setCharacterStream(int, java.io.Reader, int)
<!-- ======== NESTED CLASS SUMMARY ======== --><!-- -->
protected class |
DefaultLobHandler.DefaultLobCreator Default LobCreator implementation as inner class. |
<!-- =========== FIELD SUMMARY =========== -->
protected Log |
logger |
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
DefaultLobHandler() |
<!-- ========== METHOD SUMMARY =========== -->
InputStream |
getBlobAsBinaryStream(ResultSet rs, int columnIndex) Retrieve the given column as binary stream from the given ResultSet. |
byte[] |
getBlobAsBytes(ResultSet rs, int columnIndex) Retrieve the given column as bytes from the given ResultSet. |
InputStream |
getClobAsAsciiStream(ResultSet rs, int columnIndex) Retrieve the given column as ASCII stream from the given ResultSet. |
Reader |
getClobAsCharacterStream(ResultSet rs, int columnIndex) Retrieve the given column as character stream from the given ResultSet. |
String |
getClobAsString(ResultSet rs, int columnIndex) Retrieve the given column as String from the given ResultSet. |
LobCreator |
getLobCreator() Create a new LobCreator instance, i.e. a session for creating BLOBs and CLOBs. |
void |
setStreamAsLob(boolean streamAsLob) Specify whether to submit a binary stream / character stream to the JDBC driver as explicit LOB content, using the JDBC 4.0 setBlob / setClob method with a stream argument. |
void |
setWrapAsLob(boolean wrapAsLob) Specify whether to submit a byte array / String to the JDBC driver wrapped in a JDBC Blob / Clob object, using the JDBC setBlob / setClob method with a Blob / Clob argument. |
getBlobAsBinaryStream, getBlobAsBytes, getClobAsAsciiStream, getClobAsCharacterStream, getClobAsString |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
<!-- ============ FIELD DETAIL =========== --><!-- -->
logger
protected final Log logger
<!-- ========= CONSTRUCTOR DETAIL ======== -->
DefaultLobHandler
public DefaultLobHandler()
<!-- ============ METHOD DETAIL ========== -->
setWrapAsLob
public void setWrapAsLob(boolean wrapAsLob)
setBlob
/ setClob
method with a Blob / Clob argument.
Default is "false", using the common JDBC 2.0 setBinaryStream
/ setCharacterStream
method for setting the content. Switch this to "true" for explicit Blob / Clob wrapping against JDBC drivers that are known to require such wrapping (e.g. PostgreSQL's).
This setting affects byte array / String arguments as well as stream arguments, unless "streamAsLob"
overrides this handling to use JDBC 4.0's new explicit streaming support (if available).
PreparedStatement.setBlob(int, java.sql.Blob)
, PreparedStatement.setClob(int, java.sql.Clob)
setStreamAsLob
public void setStreamAsLob(boolean streamAsLob)
setBlob
/ setClob
method with a stream argument.
Default is "false", using the common JDBC 2.0 setBinaryStream
/ setCharacterStream
method for setting the content. Switch this to "true" for explicit JDBC 4.0 usage, provided that your JDBC driver actually supports those JDBC 4.0 operations (e.g. Derby's).
This setting affects stream arguments as well as byte array / String arguments, requiring JDBC 4.0 support. For supporting LOB content against JDBC 3.0, check out the "wrapAsLob"
setting.
PreparedStatement.setBlob(int, java.io.InputStream, long)
, PreparedStatement.setClob(int, java.io.Reader, long)
getBlobAsBytes
public byte[] getBlobAsBytes(ResultSet rs, int columnIndex) throws SQLException
LobHandler
ResultSet.getBytes
or work with ResultSet.getBlob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to usenull
in case of SQL NULLSQLException
- if thrown by JDBC methodsResultSet.getBytes(int)
getBlobAsBinaryStream
public InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException
LobHandler
ResultSet.getBinaryStream
or work with ResultSet.getBlob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to usenull
in case of SQL NULLSQLException
- if thrown by JDBC methodsResultSet.getBinaryStream(int)
getClobAsString
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException
LobHandler
ResultSet.getString
or work with ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to usenull
in case of SQL NULLSQLException
- if thrown by JDBC methodsResultSet.getString(int)
getClobAsAsciiStream
public InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex) throws SQLException
LobHandler
ResultSet.getAsciiStream
or work with ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to usenull
in case of SQL NULLSQLException
- if thrown by JDBC methodsResultSet.getAsciiStream(int)
getClobAsCharacterStream
public Reader getClobAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException
LobHandler
ResultSet.getCharacterStream
or work with ResultSet.getClob
, depending on the database and driver.
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to useSQLException
- if thrown by JDBC methodsResultSet.getCharacterStream(int)
getLobCreator
public LobCreator getLobCreator()
LobHandler
LobCreator
instance, i.e. a session for creating BLOBs and CLOBs. Needs to be closed after the created LOBs are not needed anymore - typically after statement execution or transaction completion.
LobCreator.close()
相关推荐
<bean id="lobHandler" lazy-init="true" class="org.springframework.jdbc.support.lob.OracleLobHandler"> <bean id="nativeJdbcExtractor" lazy-init="true" class="org.springframework.jdbc.support....
首先,Hibernate通过`org.hibernate.type`包中的`ClobType`和`BlobType`来映射Clob和Blob。在实体类中,你需要定义对应的属性,并使用`@Lob`注解来指示它们是大型对象: ```java import javax.persistence.Lob; ...
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"> ``` 以上配置中,`DataSourceTransactionManager`用于管理事务,而`OracleLobHandler`则...
Oracle JDBC驱动程序是连接Java应用程序与Oracle数据库的关键组件。在Oracle 12c版本中,12.2.0.1是其中一个重要的发行版,它提供了对最新Oracle数据库特性的支持,同时也增强了性能和稳定性。Oracle JDBC驱动主要有...
SQL Server JDBC驱动是微软公司为Java应用程序提供的一种与SQL Server数据库进行交互的接口。这个"sqljdbc_6.0.8112.200_chs.tar.zip"文件包含了SQL Server JDBC驱动的6.0版本,是2019年的最新更新。此驱动程序允许...
Oracle JDBC Driver是Oracle公司提供的用于Java应用程序与Oracle数据库交互的接口。它实现了Java Database Connectivity (JDBC) API,使得开发者可以使用Java语言来操作Oracle数据库,执行SQL语句,进行数据查询、...
例如,可以使用`DBMS_LOB.WRITE`在INSERT或UPDATE语句中修改LOB值,或者使用`DBMS_LOB.APPEND`在已有的LOB后面添加新内容。 学习`DBMS_LOB`包的过程中,了解其每个过程和函数的参数含义、使用场景和返回值非常重要...
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://...
3在Spring中使用org.springframework.jdbc.support.lob.OracleLobHandler处理Oracle数据库的Blob类型字段。 通过这样的设置和配置,我们就可以象持久化表的一般字段类型一样处理Blob字段了。 以上是Spring+...
<bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"> <bean id="C3PONativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0...
在 Spring 中使用 org.springframework.jdbc.support.lob.OracleLobHandler 处理 Oracle 数据库的 Blob 类型字段。通过这样的设置和配置,我们就可以象持久化表的一般字段类型一样处理 Blob 字段了。 文件上传的...
《Packt.Mastering.LOB.Development.for.Silverlight.5.A.Case.Study.in.Action》这本书专注于使用Silverlight 5进行企业级应用(LOB,Line of Business)开发的实践指导。通过对具体案例的研究,读者可以深入理解...
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="jdbc...
除了基本的CRUD操作,sqljdbc4.jar还支持高级特性,如批处理、存储过程、事务控制、游标、大型对象(LOB)操作、XML处理、时间戳比较、Unicode支持等。同时,微软的驱动还提供了一些特有的功能,例如支持MARS...
@Type(type="org.springframework.orm.hibernate3.support.BlobByteArrayType") public byte[] getTe1() { return te1; } ``` 其中,@Column 注解用于指定该字段的名称和类型,而 @Type 注解用于指定该字段的类型为...
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <value>MyEntity.hbm.xml <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect ...
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"> <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"></property> ...
**Spring 框架** Spring 是一个开源的 Java 应用框架,主要为解决企业级应用开发中的复杂性而设计。它提供了全面的事务管理、数据访问集成、AOP(面向切面编程)等核心功能。在本项目中,Spring 作为容器负责管理...
<groupId>org.springframework.boot <artifactId>spring-boot-starter-data-jpa ``` 接着,创建实体类(Entity),这是JPA与数据库交互的基础。假设我们有一个用户实体`User`,其中包含日期、大文本、二进制文本...
SQL Server JDBC驱动程序是Java应用程序连接到Microsoft SQL Server数据库的关键组件。JDBC(Java Database Connectivity)是一种标准的Java API,允许Java程序与各种数据库进行交互,包括SQL Server。本篇文章将...