Fast one-time reading Oracle Clob

xiaoxiao2021-03-06  64

A static function, direct use, the function does not take into account the case of the CLOB area data, everyone can use according to their needs

/ ** * Extract the contents of the CLOB type field from the database and convert to string * @Param RS database ResultSet, field containing the clob type * @Param Clobidx contains the index of the Clob type field in the resultset * @return Retrieving character content * @throws SQLException * / public static StringBuffer getCLOBContent (ResultSet rs, int clobidx) throws SQLException {log.debug ( "start acquisition CLOB contents, index =" clobidx); oracle.sql.CLOB clobField = ((OracleResultSet) rs) .getClob (Clobidx); Long Clen = Clobfield.length (); Char CloBarray [] = new char [(int) Clen]; int readyNum = Clobfield.getChars (1, (int) Clen, CloBarray; stringbuffer sb = new Stringbuffer (); sb.append (clobarray); log.debug ("The read clob content is [/R/N" sb.tostring() "] "); Return Sb;}

转载请注明原文地址:https://www.9cbs.com/read-119693.html

New Post(0)