private void saveBinary(InputStream in, Long userId, String remark) { Sql sql = new Sql("insert into 表名 (id,CONTENT,USER_ID,REMARK) values(序列.NEXTVAL,?,?,?)"); sql.addParameter(new Parameter(DataType.BLOB, in));//需要存的二进制文件流 sql.addParameter(new Parameter(DataType.LONG, userId));//Long类型 sql.addParameter(new Parameter(DataType.STRING, remark));//String类型 dao.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; }