生产代码如下:
public void streamImage(final String name, final OutputStream os)
throws DataAccessException {
this.simpleJdbcTemplate.getJdbcOperations().query(
"select content from imagedb where image_name=?",
new Object[] { name },
new AbstractLobStreamingResultSetExtractor() {
@Override
protected void handleNoRowFound()
throws LobRetrievalFailureException {
throw new EmptyResultDataAccessException(
"Image with name '" + name
+ "' not found in database", 1);
} @Override
protected void streamData(ResultSet rs)
throws SQLException, IOException,
DataAccessException {
InputStream inputStream = lobHandler
.getBlobAsBinaryStream(rs, 1);
if (inputStream != null) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
int length = 0;
while ((length = inputStream.read(bytes)) > 0) {
outputStream.write(bytes, 0, length);
}
os = outputStream;
if (inputStream != null) {
inputStream.close();
}
if (outputStream != null) {
outputStream.close();
}
}
}
});
}在代码行红色的位置,IDE提示错误,在内部类中如何才能正确为外部形参赋值?请帮忙解答,谢谢。
public void streamImage(final String name, final OutputStream os)
throws DataAccessException {
this.simpleJdbcTemplate.getJdbcOperations().query(
"select content from imagedb where image_name=?",
new Object[] { name },
new AbstractLobStreamingResultSetExtractor() {
@Override
protected void handleNoRowFound()
throws LobRetrievalFailureException {
throw new EmptyResultDataAccessException(
"Image with name '" + name
+ "' not found in database", 1);
} @Override
protected void streamData(ResultSet rs)
throws SQLException, IOException,
DataAccessException {
InputStream inputStream = lobHandler
.getBlobAsBinaryStream(rs, 1);
if (inputStream != null) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
int length = 0;
while ((length = inputStream.read(bytes)) > 0) {
outputStream.write(bytes, 0, length);
}
os = outputStream;
if (inputStream != null) {
inputStream.close();
}
if (outputStream != null) {
outputStream.close();
}
}
}
});
}在代码行红色的位置,IDE提示错误,在内部类中如何才能正确为外部形参赋值?请帮忙解答,谢谢。
解决方案 »
- IE会自动记录下在Input里面输入的内容,用js提交表单了,但是IE就不能记录下来了,例如:当我们使用的是<input type="button" ...on
- 生成properties文件的问题
- 关于SSH注入方式问题
- hibernateSessionFactory获得session默认的生存时间是多少
- freemarker 乱码
- Linux上安装配置使用Tomcat说明文档和JDK环境变量配置
- LDAP问题,有星的无星的都来救命啊。
- 如何将UTF-8编码转换成GB2312编码?
- 已经发布ear后,如果需要改变数据库,是不是说只要把weblogic里的data source改了就可以了?
- java 测试类启动报错
- Ext.Msg.alert
- webservice问题:服务端连数据库可以,但客户端调用webservice就不行
这里填代码
你其实没有必要再给os赋值..
重新定义一个变量让其指向os..