怎么才能把SQL里的长二进制照片导来。

来源:百度知道 编辑:UC知道 时间:2024/06/09 09:52:06
用SQL语句
图片的2进制码在表t_Item中,字段是UUID
数据库是AIS20090617093705
服务器是10.57.147.21
可以帮我写下代码马?

<body>
输出图片:
<%
String rcdId = "1";

String sql = "select photo from termPhotoIndex where rcdId = "+rcdId+" order by dtime desc";
Connection conn = Conn.getConnection();
java.sql.Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
//System.out.println(sql);
while(rs.next()) {
InputStream in = rs.getBinaryStream("photo");
ServletOutputStream op = response.getOutputStream();
int len;
byte[] buf=new byte[1024];
while((len= in.read(buf))!=-1) {
op.write(buf, 0, len);

}
op.close();
in.close();
}

rs.close();
stmt.close();
conn.close();

%>
</body>