Re: [JSP ] 從資料庫抓圖

看板java作者 ( )時間18年前 (2007/12/23 21:38), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/12 (看更多)
我在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
文章代碼(AID): #17RcJnVk (java)
討論串 (同標題文章)
文章代碼(AID): #17RcJnVk (java)