从数据库中读取blob字段并生成图片文件
来源:互联网 发布:网络机顶盒app破解版 编辑:程序博客网 时间:2024/05/18 13:30
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.lineteam.hibernate.DAO.custom.Db" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Blob" %>
<%@ page import="java.io.*" %>
<%
String pPath = request.getRealPath("/");
String sPath=pPath+"news//";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>从数据库中读取图片并生成对应的文件</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>
<%
//获取生成图片的物理路径
Connection con=Db.getConn();
Statement st=con.createStatement();
String sql="select * from news.picnews";
ResultSet rs=st.executeQuery(sql);
FileOutputStream outSTr = null;
BufferedOutputStream Buff=null;
while(rs.next())
{
try{
Blob blob = rs.getBlob("photo");
outSTr = new FileOutputStream(new File(sPath+"//"+rs.getString("path")));
Buff=new BufferedOutputStream(outSTr);
Buff.write(blob.getBytes(1, (int)blob.length()));
Buff.flush();
Buff.close();
}catch(Exception e)
{
System.out.println(e.getMessage());
}
}
%>
<br>
</body>
</html>
<%@ page import="com.lineteam.hibernate.DAO.custom.Db" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Blob" %>
<%@ page import="java.io.*" %>
<%
String pPath = request.getRealPath("/");
String sPath=pPath+"news//";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>从数据库中读取图片并生成对应的文件</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>
<%
//获取生成图片的物理路径
Connection con=Db.getConn();
Statement st=con.createStatement();
String sql="select * from news.picnews";
ResultSet rs=st.executeQuery(sql);
FileOutputStream outSTr = null;
BufferedOutputStream Buff=null;
while(rs.next())
{
try{
Blob blob = rs.getBlob("photo");
outSTr = new FileOutputStream(new File(sPath+"//"+rs.getString("path")));
Buff=new BufferedOutputStream(outSTr);
Buff.write(blob.getBytes(1, (int)blob.length()));
Buff.flush();
Buff.close();
}catch(Exception e)
{
System.out.println(e.getMessage());
}
}
%>
<br>
</body>
</html>
- 从数据库中读取blob字段并生成图片文件
- 从数据库中读取Blob对象图片并显示
- 从数据库中读取Blob对象图片并显示
- 从数据库中读取Blob对象图片并显示
- Java从数据库中读取Blob对象图片并显示
- 读取数据库中BLOB字段
- 从数据库中读取并生成图片的Servlet
- 从数据库中读取并生成图片的Servlet
- servlet实现从oracle数据库的blob字段中读出文件并显示。
- 从sql server 2000中读取image字段图片(blob),并插入到jsp中相应的页面
- hibernate从sqlserver数据库中读取图片 Image (Blob)
- (一)上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)
- (二)上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)
- 上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)(1)
- 上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)(2)
- 从XML中读取图片并生成
- 从oracle中读取blob字段
- java读取oracle数据库中blob字段
- 英文歌曲
- 商务部:我国电子商务发展亟待技术和模式创新
- Java设计模式-----State模式
- hibernate简单树型结构的实现
- 基于JSP实现图片的数据库存储与显示
- 从数据库中读取blob字段并生成图片文件
- 标准的hibernate存取blob和clob字段的方法
- 大学生的精华
- Java设计模式-----Proxy模式(静态代理)
- 深入理解sizeof
- C++中的explicit关键字
- 实现浏览器最小化功能
- xmlParser
- 关于 GridView,HyperLinkField,UrlEncode