日期:2014-05-18 浏览次数:20760 次
循环执行下面的代码时
ImageInfo image = imgService.findEntityById(ImageInfo.class, id);
InputStream is = null;
Blob img = image.getImg();
try {
if(img != null){
is = img.getBinaryStream();
}
} catch (SQLException e) {
e.printStackTrace();
}
if (is != null) {
int len = 0;
byte[] buffer = new byte[1024];
HttpServletResponse response = this.getResponse();
OutputStream out = response.getOutputStream();
while ((len = is.read(buffer)) != -1) {
out.write(buffer, 0, len);
}
out.flush();
out.close();
response.flushBuffer();
is.close();
}
出现异常
java.sql.SQLException: 关闭的连接
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.sql.BLOB.getDBAccess(BLOB.java:955)
at oracle.sql.BLOB.getBinaryStream(BLOB.java:229)
at sun.reflect.GeneratedMethodAccessor333.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.engine.jdbc.SerializableBlobProxy.invoke(SerializableBlobProxy.java:74)
at $Proxy1070.getBinaryStream(Unknown Source)
at com.hzfc.soar.lsjz.jd.action.ZlAction.writeImg(ZlAction.java:194)
at sun.reflect.GeneratedMethodAccessor379.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:358)
at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:218)
at com.opensy