clob To String - Java JDBC

Java examples for JDBC:Binary Data

Description

clob To String

Demo Code


import org.apache.log4j.Logger;
import javax.sql.rowset.serial.SerialClob;
import java.io.IOException;
import java.io.Reader;
import java.math.BigDecimal;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

public class Main{
    public static String clobToString(Clob clob) throws IOException,
            SQLException {/*w  ww .jav a  2  s.c  o  m*/
        if (clob == null)
            return null;
        Reader reader = clob.getCharacterStream();
        int c;
        StringBuilder sb = new StringBuilder();
        while ((c = reader.read()) != -1) {
            sb.append(((char) c));
        }
        return sb.toString();
    }
}

Related Tutorials