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

 

posted @ 2015-09-06 10:45  雪卜  阅读(329)  评论(0编辑  收藏  举报