67,541
社区成员
发帖
与我相关
我的任务
分享问题很奇怪,项目布署在tomcat,oc4j上都没问题,数据库用的oracle.
12/02/28 18:13:58 java.lang.Exception: 无效的列类型: getString not implemented for class oracle.jdbc.driver.T4CBlobAccessor
for (int i=0; i<nCols; i++){
if(columnType[i] == Types.CLOB)
row[i] = clobToString(rset.getClob(i+1));
else if(columnType[i] == Types.BLOB)
row[i] = blobToString(rset.getBlob(i+1));
else
row[i] = rset.getString(i+1);
}
/**
* 将"Clob"型数据转换成"String"型数据
* 需要捕获"SQLException","IOException"
* prama: colb1 将被转换的"Clob"型数据
* return: 返回转好的字符串
* @throws SQLException
* @throws IOException */
private static String clobToString(Clob colb) throws SQLException, IOException
{
String outfile = "";
if(colb != null){
//oracle.sql.CLOB clob = (oracle.sql.CLOB)colb1;
java.io.Reader is = colb.getCharacterStream();
java.io.BufferedReader br = new java.io.BufferedReader(is);
String s = br.readLine();
while (s != null) {
outfile += s;
s = br.readLine();
}
is.close();
br.close();
}
return outfile;
}
/**
* 将"Clob"型数据转换成"String"型数据
* 需要捕获"SQLException","IOException"
* prama: colb1 将被转换的"Clob"型数据
* return: 返回转好的字符串
* @throws SQLException
* @throws IOException */
private static String blobToString(Blob blob) throws SQLException, IOException
{
// Blob 是二进制文件,转成文字是没有意义的
// 所以根据传输协议,EzManager的传输协议是无法支持的
byte[] base64;
String newStr = ""; //返回字符串
if(blob!=null)
{
try {
base64 = org.apache.commons.io.IOUtils.toByteArray(blob.getBinaryStream());
newStr = new BASE64Encoder().encodeBuffer(base64);
} catch (IOException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
return newStr;
}