word文档存在oracle的blob字段中,如何用jsp在网页中把woer文档打开 请问你是使用什么平台,是linux还是windows?你怎么将word文档存在oracle的blob字段中,是否抽出word的内容? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 windows下,我要把blob字段值取出来,在网页上面显示。 呵呵,我救救你吧!Statement stmt = null;ResultSet rset = null;java.io.File outfile=null;FileOutputStream outfstrm=null;InputStream istrm=null;oracle.sql.BLOB myblob = null;outfile = new java.io.File("d:/temp/test.doc");outfstrm = new FileOutputStream(outfile);stmt = connection.createStatement();String sql = "SELECT filecontent FROM Placard WHERE placard_id = '11'";rset = stmt.executeQuery(sql);if (rset.next()){ myblob =((OracleResultSet)rset).getBLOB("filecontent"); istrm = myblob.getBinaryStream(); int strmdata; while((strmdata = istrm.read()) != -1) { outfstrm.write(strmdata); }}stmt.execute("commit");istrm.close();outfstrm.close();rset.close();stmt.close();呵呵,这样就把文件从数据库中写到服务器上d:/temp/test.doc了,你在通过页面访问就行了,具体参数自己修改一下!GOOD LUCK! 哦,少了点东东!加上:import oracle.sql.*;import oracle.jdbc.*;读完文件后自己在加些删除服务器临时文件代码就OK了! 谢谢,你的代码很好!再问:excel文件如何处理? 直接在网页上输出文件内容应该可以识别吧IE会自动调入word服务 呵呵,I服了U,你太不会转弯了吧,你保存为EXCEL文件不就行了!!!!! 很简单的:setContentType("???/word")即可,WORD的类型是什么,我忘记了,查一下配置文件的MIME部分 在输出时设置setContentType("application/msword"); 上传文件到tomcat服务的问题 Tomcat在连接jsp时遇到异常,新手求教! 什么才算是一个好项目 问两个问题? windows7 ultimate + myeclipse 8.6.0 +tomcat 7.0.4 + struts2.2.1配置问题汇总 请问javascript取得表单里的值,用在jsp程序里啊? 主名细的数据录入 JSP中的乱码问题? 请 eyeieye(魔之眼) 进来接分 linux下jsp开发环境配置 Java中是否有检查日期正确的API函数 有谁用过wsad,吐血问题,请教!!!你要几分给几分!
我要把blob字段值取出来,在网页上面显示。
ResultSet rset = null;
java.io.File outfile=null;
FileOutputStream outfstrm=null;
InputStream istrm=null;
oracle.sql.BLOB myblob = null;outfile = new java.io.File("d:/temp/test.doc");
outfstrm = new FileOutputStream(outfile);
stmt = connection.createStatement();
String sql = "SELECT filecontent FROM Placard WHERE placard_id = '11'";
rset = stmt.executeQuery(sql);if (rset.next()){
myblob =((OracleResultSet)rset).getBLOB("filecontent");
istrm = myblob.getBinaryStream();
int strmdata;
while((strmdata = istrm.read()) != -1) {
outfstrm.write(strmdata);
}
}
stmt.execute("commit");
istrm.close();
outfstrm.close();
rset.close();
stmt.close();呵呵,这样就把文件从数据库中写到服务器上d:/temp/test.doc了,你在通过页面访问就行了,具体参数自己修改一下!GOOD LUCK!
加上:
import oracle.sql.*;
import oracle.jdbc.*;读完文件后自己在加些删除服务器临时文件代码就OK了!
再问:excel文件如何处理?
应该可以识别吧
IE会自动调入word服务
setContentType("???/word")即可,WORD的类型是什么,我忘记了,查一下配置文件的MIME部分