作者cloud1203 ( )
站内java
标题Re: [JSP ] 从资料库抓图
时间Sun Dec 23 21:38:53 2007
我在DB里一笔资料可以存三个图
三个栏位分别是AttachedFile1.AttachedFile2.AttachedFile3
都是存二进位资料
参考一下网路上找到的写法
先针对AttachedFile1写了一下
con=DB.getConnection();
response.setContentType("image/jpg");
sqlcmd="select * from table where month=?";
pstmt=con.prepareStatement(sqlcmd);
pstmt.setString(1,month);
rs=pstmt.executeQuery();
while(rs.next){
BufferedInputStream jpgdata =
new BufferedInputStream(rs.getBinaryStream("AttachedFile1"));
byte[] buf = new byte[3*1024*1024];
int len;
while((len = jpgdata.read(buf,0,buf.length))!=-1){
out.write(buf,0,len);
}
}
最後的out.write(buf,0,len);会有cannot resolve symbol的问题
write的第一个参数可以吃byte吗?
还是我哪边少了些什麽?
麻烦指教<(_ _)>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 163.25.118.137