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

javaÈçºÎÀォÎļþ´æµ½Êý¾Ý¿âÖÐ

public class InsertBlobData {
Connection con = null;
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
InsertBlobData data = new InsertBlobData();
data.insertBlogInfo("002jpg", "sdsdfdf", "2007-02-12", "002.jpg");
}
public void insertBlogInfo(String jmzh, String xm, String smsj,
String fileName) throws Exception {
// try {
con = ConnectionPoliceFactory.getFactory().getConnection();
// } catch (ClassNotFoundException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// ´¦ÀíÊÂÎñ
boolean defaultCommit = con.getAutoCommit();
con.setAutoCommit(false);
Statement st = con.createStatement();
// ²åÈëÒ»¸ö¿Õ¶ÔÏó
st.executeUpdate("insert into ksren_txxx(jmzh,xm,smsj,txsj) values('"
+ jmzh + "','" + xm + "',to_date('" + smsj
+ "','yyyy-mm-dd'),empty_blob())");
// ÓÃfor update·½Ê½Ëø¶¨Êý¾ÝÐÐ
ResultSet rs = st
.executeQuery("select txsj from ksren_txxx where jmzh='"
+ jmzh + "' and xm='" + xm + "' for update");
if (rs.next()) {
// µÃµ½java.sql.Blob¶ÔÏó£¬È»ºóCastΪoracle.sql.BLOB
oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob(1);
// µ½Êý¾Ý¿âµÄÊä³öÁ÷
OutputStream outStream = blob.getBinaryOutputStream();
// ÕâÀïÓÃÒ»¸öÎļþÄ£ÄâÊäÈëÁ÷
InputStream fin = new FileInputStream(new File(fileName));
// ½«ÊäÈëÁ÷дµ½Êä³öÁ÷
byte[] b = new byte[blob.getBufferSize()];
int len = 0;
while ((len = fin.read(b)) != -1) {
outStream.write(b, 0, len);
// blob.putBytes(1,b);
}
// ÒÀ´Î¹Ø±Õ£¨×¢Òâ˳Ðò£©
fin.close();
outStream.flush();
outStream.close();
con.commit();
/* »Ö¸´Ô­Ìύ״̬ */
con.setAutoCommit(defaultCommit);
con.close();
}
}
}


Ïà¹ØÎĵµ£º

JavaÏß³Ì֪ʶÉîÈë½âÎö(2)

¶àÏ̳߳ÌÐò
¶ÔÓÚ¶àÏ̵߳ĺô¦Õâ¾Í²»¶à˵ÁË¡£µ«ÊÇ,ËüͬÑùÒ²´øÀ´ÁËijЩеÄÂé·³¡£Ö»ÒªÔÚÉè¼Æ³ÌÐòÊ±ÌØ±ðСÐÄÁôÒâ,¿Ë·þÕâЩÂé·³²¢²»ËãÌ«À§ÄÑ¡£
(1)ͬ²½Ïß³Ì
Ðí¶àÏß³ÌÔÚÖ´ÐÐÖбØÐ뿼ÂÇÓëÆäËûÏß³ÌÖ®¼ä¹²ÏíÊý¾Ý»òЭµ÷Ö´ÐÐ״̬¡£Õâ¾Í ÐèҪͬ²½»úÖÆ¡£ÔÚJavaÖÐÿ¸ö¶ÔÏó¶¼ÓÐÒ»°ÑËøÓëÖ®¶ÔÓ¦¡£µ«Java²»Ìṩµ¥¶ÀµÄlockºÍunlock²Ù×÷¡£ ......

java ËõÂÔͼ ʵÏÖ

import  java.awt.image. * ;
import  com.sun.image.codec.jpeg. * ;   
 public class poiReadDoc {
 Image img = null;
 int width = 0,height =0;
 String destFile = "";
 public void readImg(String fileName) throws IOException{
  File _fil ......

ÓÃJAX WSʵÏÖjavaµ÷ÓÃwebServic

À´¸ö¼òµ¥µãµÄ£º
1.½¨¸ö¾ßÌåµÄ·þÎñʵÏÖ£º
package com.webservice;
@WebService
public class Warehouse {
 private Map<String, Double> prices;
 public Warehouse() {
  prices = new HashMap<String, Double>();
  prices.put("Blackwell Toaster", 24.95);
 & ......

JAVAÖÐÈ¥µô¿Õ¸ñtrimº¯ÊýµÄ·½·¨

¡¡1. String.trim()
¡¡¡¡trim()ÊÇÈ¥µôÊ×β¿Õ¸ñ
¡¡¡¡2.str.replace(" ", ""); È¥µôËùÓпոñ£¬°üÀ¨Ê×β¡¢Öмä
¡¡String str = " hell o ";
¡¡¡¡String str2 = str.replaceAll(" ", "");
¡¡¡¡System.out.println(str2);
¡¡¡¡3.»òÕßreplaceAll(" +",""); È¥µôË ......

¹ØÓÚjavaµÄ++ºÍ

public class JavaPlus {

public static void main(String[] args) {
int x = 5;
x++;// x = x + 1;//ºó¼Ó¼Ó
System.out.println(x);
x--;// x = x - 1;//ºó¼õ¼õ
System.out.println(x);
++x;// x = x + 1;//ǰ¼Ó¼Ó
Sys ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ