java附件上传下载大字段版

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;
    }

 

转载于:https://www.cnblogs.com/fxfly/p/4784809.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值