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
here:

http://www.mail-archive.com/[email protected]/msg07213.html

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 = "";
        try{
            while((nextLine = br.readLine()) != null){
                char[] ca = nextLine.toCharArray();
                sb.append(nextLine+"\n");
            }
        }catch(IOException e){
                e.printStackTrace();
        }

        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.
-j

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






--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to