Java SQL ResultSet Clob Read getCLOBContent(ResultSet rs, int clobidx)

Here you can find the source of getCLOBContent(ResultSet rs, int clobidx)

Description

Gets the cLOB content.

License

Open Source License

Parameter

Parameter Description
rs the rs
clobidx the clobidx

Exception

Parameter Description
Exception the exception

Return

the cLOB content

Declaration

public static String getCLOBContent(ResultSet rs, int clobidx) throws Exception 

Method Source Code


//package com.java2s;
import java.io.Reader;
import java.sql.Clob;

import java.sql.ResultSet;

public class Main {
    /**/*from  w w w  . jav a 2  s . com*/
     * Gets the cLOB content.
     *
     * @param rs
     *            the rs
     * @param clobidx
     *            the clobidx
     * @return the cLOB content
     * @throws Exception
     *             the exception
     */
    public static String getCLOBContent(ResultSet rs, int clobidx) throws Exception {
        Clob clobField = null;
        String content = "";
        int count = 0;
        char buffer[] = new char[4086];
        clobField = rs.getClob(clobidx);
        if (clobField != null) {
            Reader reader = clobField.getCharacterStream();
            while ((count = reader.read(buffer)) > 0) {
                content = content + new String(buffer, 0, count);
            }
        }
        return content;
    }
}

Related

  1. getClobAsString(ResultSet rs, String name, String ifnull)
  2. getOracleClob(ResultSet p_rset, int p_col)
  3. readClobUTF16BinaryStream(ResultSet rs, String fieldName)