http://expert.csdn.net/Expert/topic/1197/1197476.xml?temp=.9296686

解决方案 »

  1.   

    用CLOB?给个例子吧,JDBC的:
    插入CLOB:String content=从TXT中读内容;
    try{
    java.sql.PreparedStatement pstmt = null; 
    ResultSet rs = null; 
    String query = "";  
    String key =""; Statement stmt = dbConn.createStatement ();
    rs=stmt.executeQuery("SELECT MAX(CNAME) FROM T_CLOB"); 
    if(rs.next()){     
      key = rs.getString(1); 
    if( key==null )
    key="001";
    else{
    int  intKey=Integer.valueOf(key).intValue();
    intKey+=1;
    key=Integer.toString(intKey);
    }
    }
     
    dbConn.setAutoCommit(false);        

    query = "INSERT INTO T_CLOB(CNAME,OBJ) VALUES(?,empty_clob())"; 
    java.sql.PreparedStatement Pstmt = dbConn.prepareStatement(query); 
    Pstmt.setString(1,key); 
    Pstmt.executeUpdate(); 

    Pstmt = null;
    query = "SELECT OBJ FROM T_CLOB WHERE CNAME =?  FOR UPDATE"; 
    Pstmt = dbConn.prepareStatement(query);
    Pstmt.setString(1,key);   
    rs= Pstmt.executeQuery();
    oracle.sql.CLOB clobtt = null; 
    if(rs.next()){     
    clobtt = (oracle.sql.CLOB)rs.getClob(1); 

    Writer wr = clobtt.getCharacterOutputStream(); 
    wr.write(content); 
    wr.flush(); 
    wr.close(); 
    rs.close(); 
    dbConn.commit();    
    }
        catch(Exception e){
    !@#$%^&*())*&^%$$##@#$%%^^ 哇
    }


    读CLOB:
    try{
    PreparedStatement ps = dbConn.prepareStatement("SELECT OBJ FROM T_CLOB WHERE CNAME=?");
    ps.setString(1,"5");
    ResultSet result = ps.executeQuery();
     
    if(result.next()){     
    oracle.jdbc.driver.OracleResultSet ors =(oracle.jdbc.driver.OracleResultSet)result;     
    oracle.sql.CLOB clobtmp = (oracle.sql.CLOB) ors.getClob(1);  
    ors.close();     if(clobtmp==null || clobtmp.length()==0){         
    errTmp="CLOB IS NULL";

    else{         
    buffer=clobtmp.getSubString((long)1,(int)clobtmp.length());

    }
    else{
    errTmp="NO DATA!";
    }
    ps.close();
    用socket 送buffer吧}
    catch(Exception e){
    哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇
    }
      

  2.   

    中间件
    使用pro*c或oci实现