码迷,mamicode.com
首页 > 编程语言 > 详细

java附件上传下载大字段版

时间:2015-09-06 10:57:46      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:

public int up2(Map map) {
        StringBuffer insertSQL = new StringBuffer();
        insertSQL.append("insert T_Sys_Attachment");
        insertSQL.append("(Id,A_OwnerId,A_Size,A_Title,A_Body,Type,A_Category,A_OwnerXh");
        insertSQL.append(")values(?,?,?,?,?,?,?,?) ");

        InputStream is = null;
        int row = 0;
        try {
            con.setAutoCommit(false);
            ps = con.prepareStatement(insertSQL.toString());
            /*
             * this.del(String.valueOf(map.get("a_ownerid")),
             * String.valueOf(map.get("type")));
             */
            ps.setObject(1, map.get("id"));
            ps.setObject(2, map.get("a_ownerid"));
            ps.setObject(3, map.get("a_size"));
            ps.setObject(4, map.get("a_title"));
            is = new FileInputStream((File) map.get("a_body"));
            ps.setBinaryStream(5, is, is.available());
            ps.setObject(6, map.get("type"));
            ps.setObject(7, map.get("a_category"));
            ps.setObject(8, map.get("a_ownerxh"));
            row = ps.executeUpdate();
            con.commit();

        } catch (SQLException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            this.close();
        }
        return row;
    }

 

java附件上传下载大字段版

标签:

原文地址:http://www.cnblogs.com/fxfly/p/4784809.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!