【jsp中图片无法显示】jsp中图片处理相关操作

更新时间:2014-05-06    来源:图片处理    手机版     字体:

【www.bbyears.com--图片处理】

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*,java.io.*,java.awt.Image,java.awt.image.*,com.sun.image.codec.jpeg.*"%>


<%
/*
drop table imagetable;
create table imagetable
(
   nid                            int                            not null,
   image                          blob,
   primary key (nid)
)
type = InnoDB;
*/
/*
//================ 一 、将文件写入到数据库的大字段中begin=====================
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost:3306/test?user=root&password=eastsoftweb";
Connection conn= DriverManager.getConnection(url);
java.io.File file = new File("d:/temp/1.jpg");
 FileInputStream is=new FileInputStream(file);
 PreparedStatement stmt = conn.prepareStatement(
          "INSERT INTO imagetable (nid,image)" +
"VALUES (?, ?)");  //预编译SQL语句
 stmt.setInt(1, 1);
 stmt.setBinaryStream(2, is,(int)file.length());
 stmt.executeUpdate();
 stmt.close();
 is.close();
 out.println("update end");
//===============将文件写入到数据库的大字段中end=========================
*/
/*
//====================== 二、jsp显示服务器硬盘图片示例 begin==============

本文来源:http://www.bbyears.com/ps/6123.html

猜你感兴趣