给你个例子自己看看吧
public static byte[] readBlob(ResultSet rs, String blobColumn) {
java.sql.Blob blob;
byte[] blobToByte;
InputStream inStream = null;
ByteArrayOutputStream temp = new ByteArrayOutputStream();
try {
blob = rs.getBlob(blobColumn);
inStream = blob.getBinaryStream(); byte[] data = new byte[1024];
int length = -1;
while ((length = inStream.read(data)) != -1) {
temp.write(data, 0, length);
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
} finally {
// log.debug("finally!start");
try {
if (inStream != null)
inStream.close();
} catch (IOException e) {
// log.debug("close result Exception");
}
// log.debug("finally!end");
}
blobToByte = temp.toByteArray();
try {
if (temp != null)
temp.close();
} catch (IOException e) {
// log.debug("close temp Exception");
}
return blobToByte;
}