`
hai0378
  • 浏览: 532014 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

org.springframework.jdbc.support.lob.DefaultLobHandler

 
阅读更多

<!-- ========= END OF TOP NAVBAR ========= -->

 链接如下:

http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/jdbc/support/lob/DefaultLobHandler.html


<!-- ======== START OF CLASS DATA ======== -->

org.springframework.jdbc.support.lob
Class DefaultLobHandler

java.lang.Object
  

extended by

org.springframework.jdbc.support.lob.AbstractLobHandler
      

extended by

org.springframework.jdbc.support.lob.DefaultLobHandler
All Implemented Interfaces:
LobHandler


 

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.

Since:
04.12.2003
Author:
Juergen Hoeller
See Also:
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 ======== --><!-- -->

Nested Class Summary
protected  class DefaultLobHandler.DefaultLobCreator
          Default LobCreator implementation as inner class.

 

<!-- =========== FIELD SUMMARY =========== -->

<!-- -->

Field Summary
protected  Log logger
           

 

<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<!-- -->

Constructor Summary
DefaultLobHandler()
           

 

<!-- ========== METHOD SUMMARY =========== -->

<!-- -->

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.

 <!-- -->

Methods inherited from class org.springframework.jdbc.support.lob.AbstractLobHandler
getBlobAsBinaryStream, getBlobAsBytes, getClobAsAsciiStream, getClobAsCharacterStream, getClobAsString

 <!-- -->

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

<!-- ============ FIELD DETAIL =========== --><!-- -->

Field Detail

<!-- -->

logger

protected final Log logger

<!-- ========= CONSTRUCTOR DETAIL ======== -->

<!-- -->

Constructor Detail

<!-- -->

DefaultLobHandler

public DefaultLobHandler()

<!-- ============ METHOD DETAIL ========== -->

<!-- -->

Method Detail

<!-- -->

setWrapAsLob

public 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.

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).

 

See Also:
PreparedStatement.setBlob(int, java.sql.Blob), PreparedStatement.setClob(int, java.sql.Clob)


<!-- -->

 

setStreamAsLob

public 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.

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.

 

See Also:
PreparedStatement.setBlob(int, java.io.InputStream, long), PreparedStatement.setClob(int, java.io.Reader, long)


<!-- -->

 

getBlobAsBytes

public byte[] getBlobAsBytes(ResultSet rs,
                             int columnIndex)
                      throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as bytes from the given ResultSet. Might simply invoke ResultSet.getBytes or work with ResultSet.getBlob, depending on the database and driver.

 

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as byte array, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getBytes(int)


<!-- -->

 

getBlobAsBinaryStream

public InputStream getBlobAsBinaryStream(ResultSet rs,
                                         int columnIndex)
                                  throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as binary stream from the given ResultSet. Might simply invoke ResultSet.getBinaryStream or work with ResultSet.getBlob, depending on the database and driver.

 

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as binary stream, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getBinaryStream(int)


<!-- -->

 

getClobAsString

public String getClobAsString(ResultSet rs,
                              int columnIndex)
                       throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as String from the given ResultSet. Might simply invoke ResultSet.getString or work with ResultSet.getClob, depending on the database and driver.

 

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as String, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getString(int)


<!-- -->

 

getClobAsAsciiStream

public InputStream getClobAsAsciiStream(ResultSet rs,
                                        int columnIndex)
                                 throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as ASCII stream from the given ResultSet. Might simply invoke ResultSet.getAsciiStream or work with ResultSet.getClob, depending on the database and driver.

 

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as ASCII stream, or null in case of SQL NULL
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getAsciiStream(int)


<!-- -->

 

getClobAsCharacterStream

public Reader getClobAsCharacterStream(ResultSet rs,
                                       int columnIndex)
                                throws SQLException
Description copied from interface: LobHandler
Retrieve the given column as character stream from the given ResultSet. Might simply invoke ResultSet.getCharacterStream or work with ResultSet.getClob, depending on the database and driver.

 

Parameters:
rs - the ResultSet to retrieve the content from
columnIndex - the column index to use
Returns:
the content as character stream
Throws:
SQLException - if thrown by JDBC methods
See Also:
ResultSet.getCharacterStream(int)


<!-- -->

 

getLobCreator

public LobCreator getLobCreator()
Description copied from interface: LobHandler
Create a new 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.

 

Returns:
the new LobCreator instance
See Also:
LobCreator.close()
分享到:
评论

相关推荐

    spring+hibernate操作oracle的clob字段

    &lt;bean id="lobHandler" lazy-init="true" class="org.springframework.jdbc.support.lob.OracleLobHandler"&gt; &lt;bean id="nativeJdbcExtractor" lazy-init="true" class="org.springframework.jdbc.support....

    关于在Hibernate中对于Clob,Blob字段的处理方法

    首先,Hibernate通过`org.hibernate.type`包中的`ClobType`和`BlobType`来映射Clob和Blob。在实体类中,你需要定义对应的属性,并使用`@Lob`注解来指示它们是大型对象: ```java import javax.persistence.Lob; ...

    spring oracle blob

    &lt;bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"&gt; ``` 以上配置中,`DataSourceTransactionManager`用于管理事务,而`OracleLobHandler`则...

    oracle-jdbc-12.2.0.1.zip

    Oracle JDBC驱动程序是连接Java应用程序与Oracle数据库的关键组件。在Oracle 12c版本中,12.2.0.1是其中一个重要的发行版,它提供了对最新Oracle数据库特性的支持,同时也增强了性能和稳定性。Oracle JDBC驱动主要有...

    sqljdbc_6.0.8112.200_chs.tar.zip

    SQL Server JDBC驱动是微软公司为Java应用程序提供的一种与SQL Server数据库进行交互的接口。这个"sqljdbc_6.0.8112.200_chs.tar.zip"文件包含了SQL Server JDBC驱动的6.0版本,是2019年的最新更新。此驱动程序允许...

    oracle jdbc dirver

    Oracle JDBC Driver是Oracle公司提供的用于Java应用程序与Oracle数据库交互的接口。它实现了Java Database Connectivity (JDBC) API,使得开发者可以使用Java语言来操作Oracle数据库,执行SQL语句,进行数据查询、...

    oracle dbms_lob

    例如,可以使用`DBMS_LOB.WRITE`在INSERT或UPDATE语句中修改LOB值,或者使用`DBMS_LOB.APPEND`在已有的LOB后面添加新内容。 学习`DBMS_LOB`包的过程中,了解其每个过程和函数的参数含义、使用场景和返回值非常重要...

    简单易行:Spring中操作LOB字段案例

    &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt; &lt;property name="url" value="jdbc:mysql://...

    ssh(structs,spring,hibernate)框架中的上传下载

    3在Spring中使用org.springframework.jdbc.support.lob.OracleLobHandler处理Oracle数据库的Blob类型字段。  通过这样的设置和配置,我们就可以象持久化表的一般字段类型一样处理Blob字段了。  以上是Spring+...

    spring+hibernate 解决大字段(clob)

    &lt;bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"&gt; &lt;bean id="C3PONativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.C3P0...

    SSH实现文件上传和下载

    在 Spring 中使用 org.springframework.jdbc.support.lob.OracleLobHandler 处理 Oracle 数据库的 Blob 类型字段。通过这样的设置和配置,我们就可以象持久化表的一般字段类型一样处理 Blob 字段了。 文件上传的...

    Packt.Mastering.LOB.Development.for.Silverlight.5.A.Case.Study.in.Action

    《Packt.Mastering.LOB.Development.for.Silverlight.5.A.Case.Study.in.Action》这本书专注于使用Silverlight 5进行企业级应用(LOB,Line of Business)开发的实践指导。通过对具体案例的研究,读者可以深入理解...

    Spring JdbcTemplate

    &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/&gt; &lt;property name="url" value="jdbc...

    sqljdbc4.zip

    除了基本的CRUD操作,sqljdbc4.jar还支持高级特性,如批处理、存储过程、事务控制、游标、大型对象(LOB)操作、XML处理、时间戳比较、Unicode支持等。同时,微软的驱动还提供了一些特有的功能,例如支持MARS...

    java中(注解符)处理Clob(blob)类型

    @Type(type="org.springframework.orm.hibernate3.support.BlobByteArrayType") public byte[] getTe1() { return te1; } ``` 其中,@Column 注解用于指定该字段的名称和类型,而 @Type 注解用于指定该字段的类型为...

    Spring+Hibernate处理Oracle lob字段(一)

    &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt; &lt;value&gt;MyEntity.hbm.xml &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.OracleDialect ...

    SSH+Oracle上传图片

    &lt;bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"&gt; &lt;property name="nativeJdbcExtractor" ref="nativeJdbcExtractor"&gt;&lt;/property&gt; ...

    Spring+hibernate4+SpringMVC+Jbpm4.4

    **Spring 框架** Spring 是一个开源的 Java 应用框架,主要为解决企业级应用开发中的复杂性而设计。它提供了全面的事务管理、数据访问集成、AOP(面向切面编程)等核心功能。在本项目中,Spring 作为容器负责管理...

    JPA完成单表注解配置说明包括日期,大文本,二进制文本,枚举

    &lt;groupId&gt;org.springframework.boot &lt;artifactId&gt;spring-boot-starter-data-jpa ``` 接着,创建实体类(Entity),这是JPA与数据库交互的基础。假设我们有一个用户实体`User`,其中包含日期、大文本、二进制文本...

    sqlserver jdbc jar包

    SQL Server JDBC驱动程序是Java应用程序连接到Microsoft SQL Server数据库的关键组件。JDBC(Java Database Connectivity)是一种标准的Java API,允许Java程序与各种数据库进行交互,包括SQL Server。本篇文章将...

Global site tag (gtag.js) - Google Analytics