国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

Oracle操作圖片

2024-08-29 13:46:01
字體:
供稿:網(wǎng)友
Oracle 操作圖片 
BloBTest.java
Created with JBuilderpackage 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.java
Created with JBuilder

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 揭西县| 沙田区| 仙游县| 嘉荫县| 陆河县| 葵青区| 山东省| 新河县| 宜州市| 新建县| 长子县| 固始县| 滁州市| 洪湖市| 得荣县| 阿坝| 屏东市| 锡林郭勒盟| 彰化市| 宾川县| 邵武市| 嘉鱼县| 大厂| 绥棱县| 贺州市| 岢岚县| 平邑县| 巩留县| 峡江县| 宜都市| 舞钢市| 南江县| 乐业县| 广元市| 上林县| 上栗县| 米易县| 滦平县| 延寿县| 浏阳市| 周口市|