JdbcConnect myQuery=new JdbcConnect();
ResultSet rs = myQuery.executeQuery("SELECT * FROM picture where picture_id="+pictureId);
int length = 0;
if (rs.next()) {
BLOB my_blob = (BLOB)rs.getObject("picture");
length = (int)my_blob.length();
out.print(length);
byte [] byte_array = my_blob.getBytes(1, length);
response.setContentType("image/jpeg");
ServletOutputStream sos = response.getOutputStream(); for(int i=0;i<byte_array.length;i++)
{
sos.write(byte_array[i]);
}
sos.close();
} rs.close();
myQuery.closeStmt();
myQuery.closeConn();
你试试这段程序。
ResultSet rs = myQuery.executeQuery("SELECT * FROM picture where picture_id="+pictureId);
int length = 0;
if (rs.next()) {
BLOB my_blob = (BLOB)rs.getObject("picture");
length = (int)my_blob.length();
out.print(length);
byte [] byte_array = my_blob.getBytes(1, length);
response.setContentType("image/jpeg");
ServletOutputStream sos = response.getOutputStream(); for(int i=0;i<byte_array.length;i++)
{
sos.write(byte_array[i]);
}
sos.close();
} rs.close();
myQuery.closeStmt();
myQuery.closeConn();
你试试这段程序。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货