e股脑电脑教程网
  • 首 页
  • 操作系统
  • 应用软件
  • 下载工具
  • 影音视频
  • 办公软件
  • 媒体制作
  • 网站建设
  • 平面设计
  • 数据库
  • 程序开发
  • 视频教程
编辑推荐: | 文章搜索:
您现在的位置: e股脑 >> 数据库 >> Oracle教程 >> Oracle操作图片 >> 教程正文
 
教程搜索
 
 
相关教程
  • 用Oracle 10g列值掩码技术隐藏敏感数据
  • ORACLE常用Script
  • OracleSupport全球解答的最hot的21个问
  • Oracle 中的OOP概念
  • 过程,函数,程序包
  • 异常和游标管理
  • 集合和成员函数
  • Oracle10gR2安裝
  • SQL 的高级应用
  • Install Oracle on Solaris 8/9/10
  • Install Oracle9 on RedHat
  • Start Console on Oracle9i VS Oracle
  • oracle自动imp脚本
  • Oracle9i连接sybase的透明网关的配置
  • 用裸设备来提高Oracle数据库的性能
  • 从Oracle迁移到SQL Server的陷阱
 
 

图文教程


  • Windows抢了谁的饭碗 非主流操作系统To

  • 地球还是火星 平常心看“非主流”

  • 综合运用Office 2007批量制作奖状

  • 没有系统盘如何才能修复受损系统?

  • 巧妙运用Excel中边界的附加功能!
 
 
赞 助 商
 
 
Oracle操作图片
  • 来源:e股脑
  • 点击次数:
  • 更新时间:2007-8-9
Oracle 操作图片

Blobtest.java Created with JBuilder

package testapp; import java.sql.*; import java.io.*; public class Blobtest { public Blobtest() { } public static void main (String args []) throws SQLException, IOException { //write(); read(); } static void read() throws SQLException, IOException { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // Connect to the database // You can put a database name after the @ sign in the connection URL. Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@ebizser:1521:serverdb", "scott", "tiger"); // It's faster when you don't commit automatically conn.setAutoCommit (false); // Create a Statement Statement stmt = conn.createStatement (); // Do a query to get the row with NAME 'StreamExample' ResultSet rset = stmt.executeQuery ("select col2 from lobtest where userid=1"); // Get the first row if (rset.next ()) { // Get the data as a Stream from Oracle to the client InputStream gif_data = rset.getBinaryStream (1); // Open a file to store the gif data FileOutputStream os = new FileOutputStream ("example.jpe"); // Loop, reading from the gif stream and writing to the file int c; while ((c = gif_data.read ()) != -1) os.write (c); // Close the file os.close (); } // Close all the resources if (rset != null) rset.close(); if (stmt != null) stmt.close(); if (conn != null) conn.close(); } static void write() throws SQLException, IOException { DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // Connect to the database // You can put a database name after the @ sign in the connection URL. Connection conn = //DriverManager.getConnection ("jdbc:oracle:thin:@ebizser:1521:serverdb", "scott", "tiger"); DriverManager.getConnection ("jdbc:oracle:oci8:@ebdb", "scott", "tiger"); // It's faster when you don't commit automatically conn.setAutoCommit (false); // Create a Statement File file = new File("C:\\Documents and Settings\\gzb.ECOM\\My Documents\\My Pictures\\28-3-16933_jinxishan34s.jpe"); InputStream is = new FileInputStream ("C:\\Documents and Settings\\gzb.ECOM\\My Documents\\My Pictures\\28-3-16933_jinxishan34s.jpe"); PreparedStatement pstmt = conn.prepareStatement ("insert into lobtest (userid, col2 ) values (?, ?)"); pstmt.setBinaryStream(2, is, (int)file.length ()); pstmt.setInt (1, 2); pstmt.execute (); if (pstmt != null) pstmt.close(); if (conn != null) conn.close(); } }

Blobtest.javaCreated with JBuilder

  • 上一篇教程: Oracle数据库技术(10)
  • 下一篇教程: ORACLE中一些问题的解决方法
  •  

    关于本站 | 广告联系 | 版权声明 | 使用帮助

    Copyright © 2004-2008 www.egunao.com All rights reserved.