国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 剑阁县| 浦江县| 湘潭市| 咸宁市| 米易县| 丘北县| 芦山县| 屯门区| 淮南市| 松滋市| 靖边县| 贵德县| 三河市| 寿阳县| 论坛| 专栏| 新密市| 商城县| 密山市| 鹤庆县| 象州县| 大渡口区| 公安县| 娄烦县| 丽水市| 普格县| 大丰市| 陕西省| 徐汇区| 凤凰县| 西林县| 波密县| 葵青区| 和顺县| 泸水县| 怀来县| 义马市| 玉树县| 玉树县| 雷山县| 高雄市|