用JSP怎样对ORACLE存取图片. 用JSP怎样对ORACLE存取图片. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://search.csdn.net/expert/topic/61/6101/2002/11/5/1151465.htm 也可以用过程.http://expert.csdn.net/Expert/topic/2435/2435782.xml?temp=.2710382 这是在servlet里的一个方法 public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException { performTask(request, response); } public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException { response.reset(); response.setContentType("image/jpeg"); OutputStream op = response.getOutputStream(); Blob blob = null; blob = getImgFromDB(id,type); InputStream is = null; if(blob!=null){ try{ is = blob.getBinaryStream(); } catch(Exception ex){ System.out.println("取得InputStream时产生错误:"+ex.getMessage()); } } int total = 0; int nread = 0; byte[] buffer = new byte[4 * 1024]; while ( (nread = is.read(buffer)) != -1) { op.write(buffer, 0, nread); total += nread; } op.flush(); op.close(); public Blob getImgFromDB(String id,String type){ Connection conn = null; Statement stmt = null; ResultSet rs = null; Blob oBlob = null; std nstd = new std(jndiName); String strSql = "SELECT " + idName + " ," + type + ",dbms_lob.getlength(" + type + ") FROM " + tableName + " WHERE " + idName + "=lower('" + id + "')"; //System.out.println(strSql); try{ conn = nstd.getConnection(jndiName); stmt = conn.createStatement(); rs = stmt.executeQuery(strSql); if (rs.next() && rs.getInt(3) > 0) { //有图片记录,且图片不为空 oBlob = rs.getBlob(2); } } catch(Exception fe){ System.out.println("showImage Error :" + fe.getMessage()); } finally{ try { if (rs != null) {rs.close();} if (stmt != null) {stmt.close();} if (conn != null) {conn.close();} } catch (Exception e) { System.out.print(e.getMessage()); } } return oBlob; }} 分区索引在truncate之后还存在吗,若不存在,怎么恢复呢? library hit 是什么意思啊? oracle数据库查询处理 问下:关于回滚段以及跟undo有啥关系,还有在oracle体系中什么时候用到回滚段呢等等? 请问如何实现多个表这样的关联!!! 请教一个oracle的存储过程问题~~~~~~ 求教一oracle语句! sql语句的执行过程 help!!!!! oracle出错,但不知道什么原因,因为在我自己的机器上好好的! 请高手指点 那位那有关于pl/sql developer 使用的电子文档阿? 100分的诱惑
http://expert.csdn.net/Expert/topic/2435/2435782.xml?temp=.2710382
throws javax.servlet.ServletException, java.io.IOException
{
performTask(request, response);
} public void performTask(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
throws java.io.IOException
{ response.reset();
response.setContentType("image/jpeg");
OutputStream op = response.getOutputStream(); Blob blob = null;
blob = getImgFromDB(id,type); InputStream is = null;
if(blob!=null){
try{
is = blob.getBinaryStream();
}
catch(Exception ex){
System.out.println("取得InputStream时产生错误:"+ex.getMessage());
}
} int total = 0;
int nread = 0; byte[] buffer = new byte[4 * 1024];
while ( (nread = is.read(buffer)) != -1) {
op.write(buffer, 0, nread);
total += nread;
}
op.flush();
op.close();
public Blob getImgFromDB(String id,String type){
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Blob oBlob = null; std nstd = new std(jndiName);
String strSql = "SELECT " + idName + " ," + type +
",dbms_lob.getlength(" + type + ") FROM " + tableName + " WHERE " +
idName + "=lower('" + id + "')";
//System.out.println(strSql);
try{
conn = nstd.getConnection(jndiName);
stmt = conn.createStatement();
rs = stmt.executeQuery(strSql);
if (rs.next() && rs.getInt(3) > 0) { //有图片记录,且图片不为空
oBlob = rs.getBlob(2);
}
}
catch(Exception fe){
System.out.println("showImage Error :" + fe.getMessage());
}
finally{
try {
if (rs != null) {rs.close();}
if (stmt != null) {stmt.close();}
if (conn != null) {conn.close();}
}
catch (Exception e) {
System.out.print(e.getMessage());
}
} return oBlob; }}