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

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

Oracle 操作圖片

2024-08-29 13:31:03
字體:
供稿:網(wǎng)友

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
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 油尖旺区| 新和县| 绥滨县| 镇坪县| 辽宁省| 临洮县| 古丈县| 金乡县| 兴和县| 洪泽县| 鄄城县| 大冶市| 南丹县| 遂宁市| 交口县| 盐山县| 遵义市| 长乐市| 隆安县| 凯里市| 广水市| 象山县| 广平县| 浦县| 衡水市| 巩义市| 镇远县| 墨竹工卡县| 庄河市| 徐汇区| 莆田市| 涿鹿县| 云林县| 莎车县| 许昌市| 五指山市| 阿克苏市| 唐山市| 霍城县| 永川市| 朝阳市|