Ry_jbxx_list.jsp
<%String href_edit="window.open('"+linkinfoURL+"TASK=edit&RY_ID="+jatt.RY_ID+"&RYLXBZ="+(String)request.getAttribute("RYLXBZ")+"&DWLX="+dwlx+"','ry_jbxx_edit','left=5,top=10,height=480,width=900,menubar=no,resizable=yes,location=no,toolbar=no,scrollbars=yes')";%>
Ry_jbxx_edit.jsp
在javascript代码区中增加两个函数
function pic_change()
{
document.ry_jbxx_ActionForm.show_picture.src=document.ry_jbxx_ActionForm.PIC.value;
((document.ry_jbxx_ActionForm.show_picture.fileSize/1024).toFixed(2)>1)?alert("文件大小:"+(document.ry_jbxx_ActionForm.show_picture.fileSize/1024).toFixed(2)+"kb\n\r图片长度:"+document.form1.show_picture.width+"\n\r图片高度:"+document.ry_jbxx_ActionForm.show_picture.height):alert(" 你的图片不符合规格");
}
function CaricaFoto(img)
{
try{foto1= new Image();foto1.src=(img);Controlla(img);
}catch(e){}
}
<html:form action="ry_jbxx_Action.do" styleId="ry_jbxxform" method="post" enctype="multipart/form-data">
在
<TH>身份证号:</TH>
<TD><html:text styleId="ZFZid" styleClass="BOX" property="SFZ" maxlength="18" c_type="idcard" /> </TD>
以后增加以下代码
<td rowspan="6" width="35%">
<table width="100%">
<tr>
<td>
<div align="center">
<A HREF="javascript:CaricaFoto(document.show_picture.src)" border="0">
<img name="show_picture" border="1" src="<%com.chuangda.util.web.WriteHtmlElement.get_pic(request,out);%>" width="150" height="180" >
</a>
<br />
<input type="file" name="PIC" id="PIC" alt="照片上传" width="20" class="Button_B" onchange='javascript:pic_change()'/>
</div>
</td>
</tr>
</table>
</td>
ry_jbxx_dao.java中
public boolean update_ry_jbxx(Ry_jbxx_ActionForm thisForm)里
在Dbprocess.setdeleteData(t_dsql);后增加
if(thisForm.getPIC().getFileSize()>0)
{
Dbprocess.insert_pic(thisForm.getPIC(),"RY_ID",thisForm.getRY_ID(),"T_RY_JBXX","picture");
}
在public boolean insert_ry_jbxx(Ry_jbxx_ActionForm thisForm) 函数里
Dbprocess.setinsertData(sql);后增加
if(thisForm.getPIC().getFileSize()>0)//czllfy 2007.3.29 add start
{
Dbprocess.insert_pic(thisForm.getPIC(),"RY_ID",thisForm.getRY_ID(),"T_RY_JBXX","picture");//czllfy 2007.3.29 新增加的一个函数
}
Dbprocess.java里
重载insert_pic函数,
public static boolean insert_pic(FormFile formfile,String indexname,String id,String tableName,String FiledName)
{
byte[] data = null;
boolean result=true;
int length = formfile.getFileSize();
PreparedStatement ps = null;
Statement st =null;
ResultSet rs = null;
Connection con = null;
try {
con = Dbconnection.getConnection();
con.setAutoCommit(false);
data = formfile.getFileData();
st = con.createStatement();
String sql="select "+FiledName+" from "+tableName+" where "+indexname+"='"+id+"' for update";
rs=st.executeQuery(sql);
if(rs.next()){
oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob(1);
if(blob==null){
st.execute("update "+tableName+" set "+FiledName+"=empty_blob() where " +indexname+"='"+id+"'");
rs=st.executeQuery(sql);
if(rs.next()){
blob = (oracle.sql.BLOB) rs.getBlob(1);
}
}
if (blob != null) {
BufferedOutputStream out = new BufferedOutputStream(blob.getBinaryOutputStream());
out.write(data);
out.flush();
}
con.commit();
}else
result=false;
} catch (Exception e) {
e.printStackTrace();
result=false;
}
finally{
Dbconnection.tryClose(con,st,rs);
}
return result;
}
在WriteHtmlElement.java里修改函数get_pic()的内容为
public static void get_pic(HttpServletRequest request,JspWriter out ){
String id="";
ResultSet rs = null;
String sql="";
String rootpath=request.getContextPath().toString();
int len=0;
String ywb="";
try{
id=request.getParameter("ID");
if(id==null || id.equals("")){
id=request.getParameter("RY_ID");
if(id==null||id.equals(""))
{
out.print("images/no_pic.gif");
return;
}
}
}catch(Exception e){}
ywb=(String)request.getAttribute("YW_TABLE");
if(ywb.equals("NTLJJSY_JSZK"))
{
sql="select length(a.picture) as pic from ntljjsy_jszk a where a.id='"+id+"'";
}
else if(ywb.equals("T_RY_JBXX"))//czllfy 2007.2.29 add start
{
sql="select length(a.picture) as pic from t_ry_jbxx a where a.ry_id='"+id+"'";
}//czllfy 2007.2.29 add end
else
{
sql="select length(a.picture) as pic from ntljjsy_jszk a,"+ywb+" b where a.id=b.zid and b.id='"+id+"'";
}
try {
rs=Dbprocess.getResult(sql);
if(rs.next())
{
len = rs.getInt(1);
}
else
{
out.print("images/no_pic.gif");
return;
}
if(len<=1)
out.print("images/no_pic.gif");
else{
if(ywb.equals("NTLJJSY_JSZK"))
{
out.print(rootpath+"/picwebshow?id="+id+"&zb=ntljjsy_jszk&zd=picture");
}
else if(ywb.equals("T_RY_JBXX")) //czllfy 2007.2.29 add start
{
out.print(rootpath+"/picwebshow?ry_id="+id+"&zb=t_ry_jbxx&zd=picture");
} //czllfy 2007.2.29 add end
else
{
out.print(rootpath+"/picwebshow?id="+id+"&zb=ntljjsy_jszk&ywb="+request.getAttribute("YW_TABLE")+"&zd=picture");
}
}
} catch (Exception e1) {
try {
out.print("images/no_pic.gif");
} catch (IOException e2) {
}
}
}
PicWebShow.java里
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String id = request.getParameter("id");
if(id==null||id.equals("")) //czllfy 2007.2.29 add start
{
id=request.getParameter("ry_id");
} //czllfy 2007.2.29 add end
String zb = request.getParameter("zb");
String ywb = request.getParameter("ywb");
String zd = request.getParameter("zd");
InputStream in = null;
OutputStream os = null;
try {
if (id != null)
{
response.reset();
response.setContentType(CONTENT_TYPE_JPEG);
PicDAO _dao = new PicDAO();
if(zb.equalsIgnoreCase("ntljjsy_jszk") && ywb==null)
{
in = _dao.getPic_jsz(id,zb,zd);
}
else if(zb.equalsIgnoreCase("T_RY_JBXX")) //czllfy 2007.2.29 add start
{
in=_dao.getPic_ry(id,zb,zd);
} //czllfy 2007.2.29 add end
else if(zb.equalsIgnoreCase("t_sb_cpxhb"))
{
in = _dao.getPic_jsz(id,zb,zd);
}
else
{
in = _dao.getPic(id,zb,ywb,zd);
}
os = response.getOutputStream();
int len = 10 * 1024 * 1024;
byte[] data = new byte[len];
int length = 0;
int i = 0;
System.err.println("in is null!");
if (in != null )
{
while ( (i = in.read(data)) != -1) {length++;}
System.err.println("length = " + length);
System.err.println("data = " + data.length);
if(data != null )
{
os.write(data);
}
}
}
}
catch (IOException ex) {}finally{
try {
if(in != null){in.close(); in = null;}
// if(os != null){os.close(); os = null;}
}
catch (Exception ex) {
}
}
}
picDAO.java里增加函数
public InputStream getPic_ry(String id,String zb,String zd) {
InputStream in = null;
try {
in = _sql.getPic_ry(id,zb,zd);
}
catch (Exception e) {
LogWriter.error("获取图片的流出错" + e.getMessage());
return in;
}
finally {
_sql = null;
}
return in;
}
分享到:
相关推荐
只需要安装oracle client在本地,然后配置好tns,输入连接名,用户名,密码,数据表的名称,文件名数据列名以及blob数据列名,就可以批量导出ORACLE数据库BLOB字段生成图片
2. ORACLE数据库BLOB字段:用于存储大型二进制数据,如图片、音频和视频等。 3. JSP技术:一种服务器端脚本语言,主要用于开发基于Web的应用程序。 4. JAVA类:一种面向对象的编程语言,主要用于开发桌面应用程序...
只需要安装oracle client在本地,然后配置好tns,输入连接名,用户名,密码,数据表的名称,文件名数据列名以及blob数据列名,就可以批量导出ORACLE数据库BLOB字段生成图片
基于JSP访问ORACLE数据库BLOB字段并显示图形的解决方案
java中读取ORACLE中BLOB字段存储的图片
oracle查询blob字段照片(jpeg) 像素大小sql
C#访问oracle数据库类 1、执行非查询命令 2、执行查询命令 3、带blob字段读写
kettle通过java代码将数据库blob 字段抽取到本地文件
此文档是对于oracle数据库中blob类型字段二进制大对象的读取和解析
java对oracle数据库中blob字段的处理
按照id下载存放在oracle数据库的blob字段中的内容。
从oracle中的BLOB类型字段中取出照片,转存到mysql数据库中。思路是现将oracle中的照片存储在本地文件夹,在将本地图片上传到mysql中。
oracle 存读数据库的blob字段 .net有两种方式向Oracle的blob字段中存储图片:
JDBC操纵Oracle数据库中的BLOB字段
很多朋友在操作oracle数据库的clob,blob字段时不知道怎么插入和使用,这里提供读写范例。
NULL 博文链接:https://heisetoufa.iteye.com/blog/265084
图片BASE64加密保存到数据库Blob类型中(放入数据库,并取出生成图片),完整的demo例子,可运行。
Struts用 JDBC Blob字段 保存和读取 Oracle 数据库 好用 试过 有详细注释
介绍了JSP处理图形的一种方法,该方法使用JSP访问ORACLE数据库BLOB字段,BLOB字段存储的是排样后的若干图形的坐标点,然后把坐标传递到JAVA中显示图形,在图形正中还显示了编号,充分显示了JSP结合JAVA应用的优势。
NULL 博文链接:https://heisetoufa.iteye.com/blog/262798