标签:style blog color io os ar 文件 数据 div
private void saveBinary(InputStream in, Long userId, String fieldName) { Sql sql = new Sql("insert into EEAS_USER_ATTH(id,CONTENT,USER_ID,ATTH_NAME) values(SEQ_EEAS_USER_ATTH.NEXTVAL,?,?,?)"); sql.addParameter(new Parameter(DataType.BLOB, in)); sql.addParameter(new Parameter(DataType.LONG, userId)); sql.addParameter(new Parameter(DataType.STRING, fieldName)); service.execute(sql); } public InputStream getBinary(String sql) { InputStream fis = null; Connection conn = null; PreparedStatement pstmt = null; try { conn = ContextUtil.getConnection(); // -- pstmt = conn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { fis = rs.getBinaryStream(1); } rs.close(); // -- } catch (Exception e) { e.printStackTrace(); } finally { if (pstmt != null) { try { pstmt.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } return fis; }
oracle 数据库存放读取二进制文件(将上传的文件流存在数据库)
标签:style blog color io os ar 文件 数据 div
原文地址:http://www.cnblogs.com/sisi-five/p/3991148.html