db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JDigg...@genelogic.com
Subject Village + Oracle CLOBs
Date Mon, 16 Dec 2002 22:14:25 GMT

FYI for those of us using CLOBs in Oracle, the pre-built Village that comes
w/ the TDK can't successfully return a CLOB value (apparently b/c it's
trying to stay simple, platform agnostic, etc). A post to the turbine list


gives a good solution to the problem. However, it returns an NPE for
selects on rows with null CLOB fields. Patching the proposed method to
handle this leads to:

    public static String readClob(ResultSet rs, int i) throws
java.sql.SQLException {
        Clob clob = (Clob)rs.getObject(i);

        if(clob == null)
            // The DB field is empty
            return new String();

        BufferedReader br = new BufferedReader(clob.getCharacterStream());
        StringBuffer sb = new StringBuffer();
        String nextLine = "";
            while((nextLine = br.readLine()) != null){
                char[] ca = nextLine.toCharArray();
        }catch(IOException e){

        String ColumnValue = sb.toString();
        return ColumnValue;

Figured I'd enter it in the archives for posterity; it doesn't seem to have
been addressed previously.

James Diggans
Bioinformatics Programmer
Gene Logic, Inc.
Phone: 301.987.1756
FAX: 301.987.1701

View raw message