国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
oracle中如何取出BLOB類型的值
下面是一段JSP代碼
<%@ page language="java" import="java.sql.*,java.util.*"%>
<%@ page language="java" import="oracle.sql.*"%>
<%
   String image_id ="1";
   Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();  
   String url="jdbc:oracle:thin:@172.18.16.68:1521:rz817";
   //orcl為你的數(shù)據(jù)庫的SID
   String user="hr_system";
   String password="manager";
   Connection conn= DriverManager.getConnection(url,user,password);  
   Statement stmt = conn.createStatement();
   ResultSet rs = stmt.executeQuery("SELECT * FROM tfile WHERE id = " + image_id); 
   java.io.File fileout=new java.io.File("e:/img.jpg");
   FileOutputStream op = new FileOutputStream(fileout);
   int length = 0;
  
   if (rs.next()){
       String dim_image = rs.getString("filename");      
       BLOB blocco = (BLOB)rs.getObject("info");
       length = (int)blocco.length();      
       byte [] byte_array  = blocco.getBytes(1, length);
       for(int i=0;i<byte_array.length;i++)
    {
    op.write(byte_array[i]);
    }
     /*
       for(int i=0;i<blocco.length;i++){
            op.write(blocco[i]);
        }
       */
   }
   op.close() ;  
  
   rs.close();
   stmt.close();
   conn.close();  
%>
此處可取出BLOB的值,如果想讓JSP直接顯示出圖片,用以下的代碼:
<%@ page import="com.chinsoft.web.ClientAccesss.ClientLanMuAccess"%>
<%@ page import="com.chinsoft.dataplat.access.CommonAccess"%>
<%@ page import="java.io.*,java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*"%>
<%@ page import="java.sql.*,java.sql.ResultSet"%>
<%@ page import="com.evsoft.file.*" %>
<%@ page import="com.evsoft.db.*" %>
<%@ page import="com.evsoft.util.*" %>
<%@ page import="java.sql.*" %>  
<%
 ClientLanMuAccess Access=new ClientLanMuAccess();
 int data_num=Access.GetReportMaxID(request.getParameter("FileID"));
 int intpage = 1;
 String FileID=request.getParameter("FileID");
 if (request.getParameter("page") != null)
    intpage = Integer.parseInt(request.getParameter("page"));
                Connection conn=null;
                ResultSet rs=null;
                PreparedStatement ps=null;
try
{
        conn = new CommonAccess().createConnection();
        //ps =conn.prepareStatement( "Select Report_Img from WEB_Report Where Report_ID="+intpage+" and LIEBIAO_ID="+FileID+" ");
        ps =conn.prepareStatement( "select report_img from web_report where liebiao_id=15 and report_id=37");
    rs = ps.executeQuery();
   if (rs != null)
   {     
    System.out.println("sa1");
    while (rs.next())
    {
       System.out.println("sa2");
            ServletOutputStream sout = response.getOutputStream();
            response.setContentType("image/jpeg");
            InputStream in = rs.getBinaryStream(1);
            byte b[] = new byte[0x7a120];
            for(int i = in.read(b); i != -1;)
           {
             sout.write(b);
             in.read(b);
           }
            in.close();
           sout.flush();
           sout.close();   
    }
    rs.close();
   }
   ps.close();
}
catch (SQLException e)
{
   e.printStackTrace();
}
finally
{
try
{
System.out.println("err_test_sam!222");
  if (rs != null)
   rs.close();
  if (ps != null)
   ps.close();
  if (conn != null)
   conn.close();
   
}
catch (Exception e)
{
 System.out.println("err_test_sam!000");
}
}
%>
 
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Oracle中插入圖片并顯示(用BLOB類型)
使用JDBC和Hibernate來寫入Blob型數(shù)據(jù)到Oracle中
oracle Blob 文件讀寫
Java大對(duì)象類型的Hibernate映射
用jspsmartupload進(jìn)行上傳下載(數(shù)據(jù)庫)
Blog 圖片
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服