img显示从数据库取出blob字段

@RequestMapping("/getPictureForpeople")public void getPictureForpeople(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {    Connection conn = null;    conn = GetJDBCConnection.getJDBCConnection();    Statement stmt = conn.createStatement();    String getPicSQL = "select header from lc0039999.idmidentityinfo where code = ‘houzt‘";    ResultSet rs = stmt.executeQuery(getPicSQL);    Blob img=null;    if(rs.next()) {        img = rs.getBlob("header");    }    long size=img.length();    byte[] bs=img.getBytes(1, (int)size);   // response.setContentType("image/jpeg");    ServletOutputStream outs=response.getOutputStream();    outs.write(bs);    outs.flush();}
<img src="${ctx}/PersonPages/getPictureForpeople" style="width: 100px;height:120px;border:5px solid #104365;clear: both; display: block; margin:auto; "/>
时间: 2024-07-30 06:47:55

img显示从数据库取出blob字段的相关文章

java读取oracle数据库中blob字段

测试表 create table TEST_IMG ( ID INTEGER not null, NAME VARCHAR2(32), IMAGE BLOB ); 说明: 1.使用JDBC演示 2.IMAGE字段存储一个图片 程序代码如下: import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; im

JSP读取Oracle数据库里的图片Blob字段并显示在页面上&lt;转&gt;

java代码:首先定义一个读取Oracle数据库的Blob字段并把字节写入一个输出流的方法. 1 public static void writeImg(OutputStream os) { 2 Connection con; 3 try { 4 con = ConnectionFactory.getConnection(); 5 Statement stmt = con.createStatement(); 6 ResultSet rs = stmt.executeQuery("select

Java读取/更新Oracle数据库blob字段

在写java程序过程中,如何读取Oracle数据库表某类型为blob的字段? 以下是我在写程序的时候一种解决方法.核心语句.(传上来做了修改,格式不要学习,养成良好习惯) 详细请参考: 读取序列ID:http://blog.csdn.net/yzsind/article/details/6918506 BLOB相关:http://jslfl.iteye.com/blog/1771949 http://www.linuxidc.com/Linux/2011-08/40218.htm http://

通过RF数据库查询中文字段结果正常显示的转换方法

1.通过RF数据库查询中文字段结果格式:'\xba\xcb\xbc\xf5\xcd\xa8\xb9\xfd' 2.通过Decode Bytes To String进行gbk解码即可正常显示:

Oracle如何通过dataLink复制远程数据库的CLOB\BLOB字段数据到本地数据库

Oracle不支持直接通过Database Link复制远程数据库表的CLOB/BLOB字段数据到本地数据库. 像如下的SQL是不能执行的.(ipop_topic表有一个CLOB的字段) insert into ipop_topicselect * from [email protected] where application_id=1000 但是,我们可以借助全局临时表,先把数据复制到临时表,再从临时表转移到你的目的表. create global temporary table ipop_

Oracle数据库BLOB字段的存取

述]     Oracle的Blob字段比较特殊,他比long字段的性能要好很多,可以用来保存例如图片之类的二进制数据. 写入Blob字段和写入其它类型字段的方式非常不同,因为Blob自身有一个cursor,你必须使用cursor对 blob进行操作,因而你在写入Blob之前,必须获得cursor才能进行写入,那么如何获得Blob的cursor呢? 这需要你先插入一个empty的blob,这将创建一个blob的cursor,然后你再把这个empty的blob的cursor 用select查询出来

JAVA读取Oracle数据库BLOB字段数据文件并保存到本地文件

******JAVA读取Oracle数据库BLOB字段数据文件并保存到本地文件****** package com.bo.test; import java.io.FileOutputStream; import java.io.InputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import

对oracle数据库Blob字段的操作

java实体类 定义类型 byte[] private byte[] str_blob hibernate映射文件类型oracle.sql.BLOB <property name="str_blob" type="oracle.sql.BLOB"> <column name="STR_BLOB" /> </property> 数据库类型BLOB byte[] b = str.getBytes(); String

C#读取Mysql blob字段 (转帖)

http://blog.csdn.net/config_man/article/details/6123191 开发环境:Windows XP Professional SP3.VS2008.Winform.MySQL5.0.MySQL.Data.dll 6.2.3.0 1.从硬盘上读取一图片,将其转化为流,然后存储到此BLOB字段中 [csharp] view plaincopyprint? private void button1_Click(object sender, EventArgs