搜索

Oracle应用开发中的几个经典问题

发表于 2025-11-04 07:52:17 来源:全栈开发

File file = new File("aaa.gif");   int fileLength =(int) file.length();

  InputStream fin = new FileInputStream(file);

Oracle应用开发中的几个经典问题

  PreparedStatement pstmt =

  con.prepareStatement("insert into tb_file values(aaa.gif,应用?)");

  pstmt.setBinaryStream (1, fin, fileLength); pstmt.executeUpdate();

  如果你一定要用BLOB存储,你就必须用ORACLE自己的企商汇个经方法:

  create table tb_file(name varchar(20),detail BLOB);

  con.setAutoCommit(false);

  stmt.executeUpdate

  ("insert into tb_file values(aaa.gif,empty_blob())");

  下面必须SELECT得到BLOB的免费源码下载对象再向里写:

  rs = stmt.executeQuery

  ("select detail from tb_file where name=aaa.gif for upfdate" );

  if(rs.next()) { Blob blob = rs.getBlob(1);

  BinaryOutputStream out =

  ((oracle.sql.BLOB)blob).getBinaryOutputStream();

  byte[] b = new byte[((oracle.sql.BLOB)blob).getBufferSize];

  InputStream fin = new FileInputStream(file);

  int len = 0; while( (len = fin.read(b)) != -1) out.write(b,0,len);

  fin.close(); out.close(); con.commit();

}

高防服务器
随机为您推荐
版权声明:本站资源均来自互联网,如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

Copyright © 2016 Powered by Oracle应用开发中的几个经典问题,全栈开发  滇ICP备2023006006号-32sitemap

回顶部