Oracle blob demo
2015-11-11 17:07
645 查看
public void saveBlob(String path) throws SQLException, FileNotFoundException, IOException { //ITRDR_environment.xlsx PreparedStatement pstmt= connection.prepareStatement("update blob_FILE set file =?where id =123456");
InputStream is = new FileInputStream(path+"22.xlsx"); pstmt.setBinaryStream(1, is,is.available()); pstmt.executeUpdate(); connection.commit(); is.close(); } public void getBlob(String path) throws SQLException, FileNotFoundException, IOException { String query = "SELECT FILE FROM blob_FILE where id =123456"; java.sql.Blob blob= null; preparedStatement = connection.prepareStatement(query); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { blob = resultSet.getBlob("FILE"); } InputStream ins= blob.getBinaryStream(); OutputStream ops = new FileOutputStream(new File(path+"11.xls")); byte[]b = new byte[1024]; int len = 0; while((len=ins.read(b))!=-1) { ops.write(b, 0, len); } ops.close(); ins.close(); }
相关文章推荐
- Oracle BLOB内容批量导出
- oracle.sql.TIMESTAMP
- oracle 多表联合更新
- ppa 安装oracle jdk 7 或者 jdk 8
- Oracle OAF XML文件导入导出
- Oracle中清除游标缓存的几种方法
- 如何配置pl/sql 连接远程oracle服务器
- oracle管理、备份恢复、数据字典
- Oracle总结
- oracle事务以及sql函数
- [转]C#连接Oracle数据库(直接引用dll使用)
- Oracle Advanced Queue (DBMS_AQ/DMBS_AQADM)
- hibernate中oracle库时间格式执行 2015/11/11 15:10:01错误原因
- oracle 授权
- oracle归档模式和非归档模式的区别
- ORACLE创建表时添加列说明
- ORACLE中sequence用法
- linux下Oracle Instant Client安装(rpm、zip)
- navicat连接Oracle使用说明
- oracle 控制文件