如何把Oracle数据库中的blob转成pdf格式 我先是把一个pdf格式的文档转成blob然后存在Oracle数据库里面,现在要取出来用应该怎么办呢?此外,取出来的pdf,要是想显示在网页上又应该如何,大家有什么好点的思路? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 二进制流,输出到.pdf不就好了? 看官网怎么做的:http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html 我项目中一个取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; }抱歉 一些 表 字段 还有文字描述 去掉了 我是想先从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 你的结果存在char[] buffer = new char[10];这个里面,可是我需要的是pdf的 Oracle与SSH框架集成spring配置文件怎么写? 达人帮我写个bat批处理文件运行jar包 一个父子关系的接口设计 同一个包中的类不能引用是为什么?急,明天就要答辩,望救我一命!! 在oracle中如何对rs使用beforefist() HELP!Borland JBuilder X Enterprise v10.0的注册码多少啊!!!!! 如何给窗口设计个性化的skin java中类似memset的函数是什么? 什么java反编译器好用?????? 路人甲老兄请看! C#加密算法改成Java实现,谁来帮我下啊? java的疑问
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html
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;
}
抱歉 一些 表 字段 还有文字描述 去掉了
<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