Re: [JSP ] 從資料庫抓圖
我在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
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 3 之 12 篇):