`
zgqynx
  • 浏览: 1355783 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

oracle java 插入 clob insert clob hibernate

阅读更多
用jdbc 或者 hibernate
http://www.weste.net/2004/11-3/12250047377.html

oracle 10g 处理clob
http://blog.csdn.net/fenglibing/archive/2006/04/19/669476.aspx


好的文章
http://www.herongyang.com/jdbc/Oracle-CLOB-setClob.html

解决实例:
http://forum.java.sun.com/thread.jspa?threadID=349880&messageID=2778347
onvert String to CLOB and Insert into Oracle database  
Jan 23, 2003 4:59 AM

Click to email this message



Hi,

I spent some time working on this, and I thought I would share it within the forum. This solution is unique to Oracle, so consider it's use carefully. It's the simplest coding I could come up with, and I have been able to insert Strings of any length using this technique with both the oci8 and thin driver when executed using Java 1.4 and Oracle 9.2. No guarantees that it will work for you. Let me know if it helps you out.
import java.sql.*;
import java.util.*;
import java.text.*;
 
/* -------------------------------------------------------------------
 * This program demonstrates a technique for converting a large String
 * to an oracle.sql.CLOB then inserting that CLOB into a database.  
 * I believe most of this is specific to Oracle, specifically the 
 * ability to create a temporary CLOB within your program.
 * -------------------------------------------------------------------
 */
class TestOraCLobInsert {
	
    public static void main (String args []) throws SQLException {
			
        try {
 
            DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
            Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@server:1521:sid", "uid", "pwd");
 
            PreparedStatement ps = conn.prepareStatement("INSERT INTO CLOBTABLE VALUES (?)");
            
            oracle.sql.CLOB newClob = oracle.sql.CLOB.createTemporary(conn, false, oracle.sql.CLOB.DURATION_CALL);
            
            newClob.putString(1,"This string, up to 4 gigabytes will be inserted into the CLOB");
            
            ps.setClob(1, newClob);
            
            int rowcnt = ps.executeUpdate();
            
            System.out.println("Successful update of "+rowcnt+" row");
            
            ps.close();
            conn.close();            
        }
        catch (Exception e) {
            System.out.println("Java Exception caught, error message="+e.getMessage());
        }
    }
 
}


分享到:
评论

相关推荐

    hibernate存取oracle的clob

    ### Hibernate 存取 Oracle 的 CLOB 在 Java 开发中,使用 Hibernate 框架进行数据库操作是非常常见的。其中,处理 Oracle 数据库中的 CLOB 类型数据是一项重要的技能。CLOB(Character Large Object)是一种用于...

    Hibernate存储Clob字段的方式总结

    Hibernate存储Clob字段的方式总结涉及了在Java开发中使用Hibernate操作大型文本字段Clob的操作方法。本文主要介绍了两种操作Clob字段的方法,一种是将Clob字段直接映射为String类型,另一种是使用Clob类型进行处理。...

    使用hibernate对oracle读取blob

    Hibernate作为一款流行的ORM(对象关系映射)框架,提供了与Oracle数据库交互的简便方式,包括处理Blob数据。本文将详细介绍如何使用Hibernate和JDBC读取和存储Oracle数据库中的Blob对象。 ### 1. Hibernate Blob...

    java将图片写入数据库,并读出来(blob clob)

    这个过程通常涉及到Blob和Clob数据类型,它们是Java中的两种特殊对象,用于存储大对象(LOB)。Blob用于存储二进制数据,如图片、音频或视频文件,而Clob则用于存储字符数据,比如长文本。以下是如何使用Java处理...

    解析使用jdbc,hibernate处理clob/blob字段的详解

    在Java的数据库操作中,`CLOB...总之,无论是使用JDBC还是Hibernate,处理`CLOB`和`BLOB`字段都需要特殊的处理方式,尤其是在Oracle等数据库中。了解这些处理方法对于开发涉及大数据量文本和二进制数据的应用至关重要。

    使用Jdbc4操作Blob,Clob

    "INSERT INTO my_table (blob_column, clob_column) VALUES (?, ?)"); // Blob处理 File file = new File("path/to/your/file.jpg"); FileInputStream fis = new FileInputStream(file); pstmt.setBlob(1, fis, ...

    详解jdbc实现对CLOB和BLOB数据类型的操作

    oracle.sql.CLOB clob = (oracle.sql.CLOB) rs.getClob("CLOBATTR"); Writer outStream = clob.getCharacterOutputStream(); // data是传入的字符串,定义:String data outStream.write(data.toCharArray()); ...

    仿hibernate动态生成sql保存对象

    在实现过程中,`Oracle字段映射动态`可能指的是针对Oracle数据库的特殊处理,例如Oracle的CLOB和BLOB类型映射,或者考虑Oracle特有的数据类型和特性。确保你的解决方案能适配不同的数据库系统,因为它们可能有不同的...

    oraclejdbc.rar_Java编程_Java_

    描述中提到的“实现了用java操作数据库的功能”,这涉及到Java编程语言的基础知识,特别是其面向对象的特性,以及如何使用Java的JDBC API来执行SQL语句,如SELECT、INSERT、UPDATE和DELETE等。"java+MyEclipse+...

    SQL生成Java项目

    【SQL生成Java项目】是一个基于ORACLE数据库的开发工具,旨在帮助程序员高效地将数据库中的表结构转换为Java代码,从而简化数据访问层(DAL)的开发工作。这个项目的核心功能是通过解析ORACLE的建表语句,自动生成...

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

     文件数据存储在Blob类型的FILE_CONTENT表字段上,在Spring中采用OracleLobHandler来处理Lob字段(包括Clob和Blob),由于在程序中不需要引用到oracle数据驱动程序的具体类且屏蔽了不同数据库处理Lob字段方法上的...

    oracle基础练习.docx

    SSH、Struts、Spring和Hibernate等技术与Oracle的集成可以构建复杂的Web应用程序。SpringMVC、Spring和iBatis组合的SSI框架也是常见的Web开发架构。 配置Oracle监听器是连接数据库的关键步骤,监听器配置文件...

    oracle入门基础教程全面详细

    - **插入数据**:学习INSERT语句的使用方法。 - **更新数据**:掌握UPDATE语句的应用场景。 - **删除数据**:学习DELETE语句的使用技巧。 - **批量操作**:介绍批量插入、更新数据的方法。 #### 十四、约束 - **...

    数据库的各种连接技巧

    Oracle JDBC驱动提供了处理大型对象(如BLOB和CLOB)的功能。通过`PreparedStatement`中的`setObject()`、`setBinaryStream()`和`setCharacterStream()`等方法,可以方便地读取和写入LOB数据。例如: ```java ...

    Oracle数据库的基础使用

    开发框架如SSH(Struts+Spring+Hibernate)和SSI(SpringMVC+Spring+IBatis)经常与Oracle配合使用。 配置监听器是Oracle数据库管理的重要环节,监听器文件(如Oracle.Listener和OracleService)负责处理客户端连接...

Global site tag (gtag.js) - Google Analytics