1
我书面方式代码上传文件的Oracle作为BLOB但同时保存该文件它给我的异常值java.sql.SQLException:ORA-01460:未实现或不合理图片上传问题
以下是功能转换我的BLOB类型的ByteArray
private byte[] convertToByteArray(Blob fromBlob) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
return convertToByteArrayImpl(fromBlob, baos);
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (baos != null) {
try {
baos.close();
} catch (IOException ex) {
}
}
}
}
private byte[] convertToByteArrayImpl(Blob fromBlob, ByteArrayOutputStream baos)
throws SQLException, IOException {
byte[] buf = new byte[4000];
InputStream is = fromBlob.getBinaryStream();
try {
for (;;) {
int dataSize = is.read(buf);
if (dataSize == -1)
break;
baos.write(buf, 0, dataSize);
}
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ex) {
}
}
}
return baos.toByteArray();
}
我认为它是因为我的字节长度大于4000但,什么是解决方案,节省超过4000个字节?
您使用的是什么版本的Oracle JDBC驱动程序? – skaffman 2010-02-08 08:40:46
和什么版本的Oracle? – Thilo 2010-02-08 08:42:27
我正在使用oracle 10G并使用ojdbc14.jar – Vipul 2010-02-08 11:18:08