Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java²Ù×÷oracleÊý¾Ý¿âÖеÄblob×Ö¶Î

oracleÖеÄBLOB×Ö¶ÎÊÇ´æ´¢2½øÖƵÄÎļþ£¬±ÈÈçÎļþ£¬Í¼Æ¬µÈ¡£
1¡¢°Ñ±¾µØÎļþдÈëÊý¾Ý¿â
package com.data;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
public class WriteBlob {
/**
* beckham 2009-12-7 ÏÂÎç09:47:36
*/
public static void main(String[] args) throws Exception {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url = "jdbc:oracle:thin:@localhost:1521:menhu";
String user = "zm";
String password = "zm";
Connection conn = DriverManager.getConnection(url, user, password);
// ÉèÖÃÊÖ¶¯Ìá½»
conn.setAutoCommit(false);
Statement sta = null;
ResultSet rs = null;
PreparedStatement ps = null;
// ²åÈë¿ÕÖµ
String sql = "insert into mytest values(3,empty_blob()) ";
sta = conn.createStatement();
sta.executeUpdate(sql);
conn.commit();
// Ëø¶¨²¢±à¼­µ±Ç°Êý¾Ý
sql = "select images from mytest where id=3 for update";
rs = sta.executeQuery(sql);
if (rs.next()) {
oracle.sql.BLOB b = (oracle.sql.BLOB) rs.getBlob("images");
// ÊäÈëÁ÷
OutputStream os = b.getBinaryOutputStream();
// Êä³öÁ÷
FileInputStream fiis = new FileInputStream(new File("1.doc"));
// Èë¿â
byte[] tmp = new byte[1024];
int a = 0;
while ((a = fiis.read(tmp)) != -1) {
os.write(tmp, 0, a);
os.flush();
}
os.close();
fiis.close();
}
conn.commit();
rs.close();
sta.close();
conn.close();
}
}
 
2¡¢´ÓÊý¾Ý¿âÖжÁÈ¡Blob×Ö¶ÎÊý¾Ý
package com.data;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class ReadBlob {
/**
* beckham 2009-12-8 ÏÂÎç03:49:30
*/
public static void main(String[] args) throws Exception


Ïà¹ØÎĵµ£º

oracle ±í¿Õ¼ä²Ù×÷

oracle±í¿Õ¼ä²Ù×÷Ïê½â
  1
  2
  3×÷Õߣº   À´Ô´£º    ¸üÐÂÈÕÆÚ£º2006-01-04 
  5
  6 
  7½¨Á¢±í¿Õ¼ä
  8
  9CREATE TABLESPACE data01
 10DATAFILE '/ora ......

jdbcÁ¬½ÓOracle

      ËäȻѧϰJavaºÜ¾ÃÁË£¬×Ô¼ºÒ²Á¬½Ó¹ýһЩÊý¾Ý¿â£¬±ÈÈçmysqlÖ®ÀàµÄ£¬Èç½ñÄØ£¬Ò²Ñ§Ï°ÁËÒ»¶Îʱ¼äµÄOracle£¬È»¶øÄØ£¬½ñÌìÊÇÎÒµÚÒ»´ÎÁ¬½ÓOracle£¬ºÙºÙ£¬Ó¦¸Ã»¹²»ËãÌ«³Ù°É¡£
    ½ñÌìÄØ£¬Óе㱿׾£¬´ó¼ÒĪЦ£¡
    ÎÒÕâÊÇÒ»¸ö²éѯÀý×Ó
    Ê×ÏÈ£¬Ô ......

javaÖÐ120¸ö¾­µäÎÊÌâ2

31¡¢EJB°üÀ¨£¨SessionBean,EntityBean£©Ëµ³öËûÃǵÄÉúÃüÖÜÆÚ£¬¼°ÈçºÎ¹ÜÀíÊÂÎñµÄ£¿
    SessionBean£ºStateless Session Bean µÄÉúÃüÖÜÆÚÊÇÓÉÈÝÆ÷¾ö¶¨µÄ£¬µ±¿Í»§»ú·¢³öÇëÇóÒª½¨Á¢Ò»¸öBeanµÄʵÀýʱ£¬EJBÈÝÆ÷²»Ò»¶¨Òª´´½¨Ò»¸öеÄBeanµÄʵÀý¹©¿Í»§»úµ÷Ó㬶øÊÇËæ±ãÕÒÒ»¸öÏÖÓеÄʵÀýÌṩ¸ø¿Í»§»ú¡£µ±¿Í»§»úµÚÒ» ......

javaѧϰС¼¼ÇÉ

1¡¢byteͨ³£ÓÃÀ´½øÐÐλÔËË㣬λ¿í¶ÈÕ­£¬Ò»°ã²»ÓÃÀ´¼ÆËã
2¡¢¹Ø¼ü×Ö¶¼ÊÇСдµÄ£¬ÔÚeclipseÖÐÏÔʾΪºìÉ«¡£
3¡¢±äÁ¿¸øÁËȱʡµÄ³õʼֵ£¬CÓïÑÔû¸ø£¬Ö»¸ø·ÖÅäÁ˿ռ䣬ÀïÃæµÄÊý²»È·¶¨
4¡¢charµÄȱʡֵÊÇASCIIÂëÖеÚ1¸ö
5¡¢ÔËÐÐЧÂÊ£ºi++>i+=1>i=i+1
6¡¢²¼¶ûÖµ²»ÄܽøÐдóС±È½Ï£¬Ö»ÄܽøÐÐ==±È½Ï
7¡¢ÏÈËã&&ÔÙËã| ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ