You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by JD...@genelogic.com on 2002/12/16 23:14:25 UTC
Village + Oracle CLOBs
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/turbine-user@jakarta.apache.org/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