`
zgqynx
  • 浏览: 1342063 次
  • 性别: 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());
        }
    }
 
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics