我先是把一个pdf格式的文档转成blob然后存在Oracle数据库里面,现在要取出来用应该怎么办呢?
此外,取出来的pdf,要是想显示在网页上又应该如何,大家有什么好点的思路?

解决方案 »

  1.   

    二进制流,输出到.pdf不就好了?
      

  2.   

    看官网怎么做的:
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html
      

  3.   

    我项目中一个取clob 的例子不知道有帮助没public String ************(String id) {
    String sql = "select *** from *** where ID='"
    + id + "'";
    final StringBuffer clobBuffer = new StringBuffer();
    final LobHandler lobHandler = new OracleLobHandler(); jdbcTemplate.query(sql, new AbstractLobStreamingResultSetExtractor() {
    protected void handleNoRowFound()
    throws LobRetrievalFailureException {
    log
    .info("There is no matched data.in ****");
    }; protected void streamData(ResultSet rs) throws SQLException,
    IOException, DataAccessException {
    java.io.Reader clobStream = lobHandler
    .getClobAsCharacterStream(rs, "***");
    if (clobStream == null) {
    clobBuffer.append("<html>");
    clobBuffer.append("<head>");
    clobBuffer
    .append(" <meta http-equiv=\"content-type\" content=\"text/html; charset=gb2312\">"); clobBuffer.append("<style type=\"text/css\">");
    clobBuffer.append("<!--");
    clobBuffer.append("#nav {padding:0px;list-style-type:none;margin:0;}"); clobBuffer.append("#nav li{");
    clobBuffer.append(" font-size:16px;");
    clobBuffer.append(" font-family: \"宋体\";");
    clobBuffer.append("line-height: 20px;");
    clobBuffer.append("}"); clobBuffer.append("#nav_01 {padding:0px;list-style-type:none;margin:0;}");
    clobBuffer.append("#nav_01 li{");
    clobBuffer.append(" font-size:16px;");
    clobBuffer.append("font-family: \"宋体\";");
    clobBuffer.append("line-height: 20px;");
    clobBuffer.append("font-weight: bold;");
    clobBuffer.append("}");
    clobBuffer.append("-->");
    clobBuffer.append("</style>");
    clobBuffer.append("</head>");
    clobBuffer.append("<body>");
    clobBuffer.append("<li><font color=\"blue\">***************。</font></li>");
    clobBuffer.append("</body>");
    clobBuffer.append("</html>");
    return;
    }
    // 得到clob数据
    int nchars = 0;
    char[] buffer = new char[10];
    while ((nchars = clobStream.read(buffer)) != -1) {
    clobBuffer.append(buffer, 0, nchars);
    }
    clobStream.close();
    log.info("---------******:" + clobBuffer.toString());
    }
    });
    String messContent = clobBuffer.toString();
    log.info("---------*********:" + clobBuffer.toString());
    return xxxxxxx;
    }
    抱歉 一些  表 字段  还有文字描述 去掉了 
      

  4.   

    我是想先从Oracle中取出pdf, 然后把这个pdf嵌入到网页里面假设取出来没问题,那个怎么嵌进网页?<%@ page language="java"  pageEncoding="UTF-8"%><html>
      <head>
        <title>Test</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->  </head>
      
      <body>
      <object  classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"   width="760"   height="411"   border="0">
            <param   name="SRC"   value="Heosemys.pdf">
        </object>

      </body>
    </html>
    网上说这样可以,但是我在页面里发现没有显示,此外点击刷新时可以看见
    “已下载0B/1020B http://localhost:8888/linhai/Heosemys.pdf
      

  5.   

    你的结果存在char[] buffer = new char[10];这个里面,可是我需要的是pdf的