我这有个原来不知道哪儿copy的例子import java.io.*;
import java.util.*;
import java.sql.*;import java.text.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */public class writeBean {
  private String sample = "";
  //Access sample property
  public String getSample() {
    return sample;
  }
  //Access sample property
  public void setSample(String newValue) {
    if (newValue!=null) {
      sample = newValue;
    }
  }
  
  private String filename = "";
  //Access sample property
  public String getFilename() {
    return filename;
  }
  //Access sample property
  public void setFilename(String newValue) {
    if (newValue!=null) {
      filename = newValue;
    }
  }
    public  void gwrite() throws SQLException,IOException
  {
   
    PreparedStatement stmt = null;
    ResultSet rs =  null;
    InputStream fin = null;
    OutputStream fout = null;
    Connection conn=null;
    try{
    
    newhua.dbbean  db=new newhua.dbbean();
    db.InitDatabase();
    conn =db.conn;
    //conn.setAutoCommit(false);
    System.out.println(sample);
    System.out.println(filename);
    //String filename;
    //
    //filename="c:/tomcat/webapps/nw/lsdoc/"+sample+".sxw"; 
    String mysql= "select word from tmanuscript where glidenumber='"+sample+"' for update";
    System.out.println(mysql);  
    stmt=conn.prepareStatement(mysql);
    //stmt.setString(1,sample);
    rs=stmt.executeQuery() ;
    //System.out.println();
    if(rs.next()) {
System.out.println(sample);
System.out.println(filename);
BLOB blob = ((OracleResultSet)rs).getBLOB("word");
fout = blob.getBinaryOutputStream();
File f = new File(filename);
fin = new FileInputStream(f);
byte[] buffer = new byte[blob.getBufferSize()];
int bytesRead = 0;
while((bytesRead = fin.read(buffer)) != -1) 
{
fout.write(buffer, 0, bytesRead);
System.out.println(bytesRead);
} blob = null;
f = null;
buffer = null;
fin.close();
fout.close();
conn.commit();
}
  }
  catch(Exception ex)
    {
ex.printStackTrace();  }

finally {
try {



fin = null;
fout = null;
rs = null;
conn = null;
stmt = null;
}
                        catch(Exception e) {
e.printStackTrace();
}
                        }
}public void gread() throws SQLException,IOException
{
Connection conn = null;
PreparedStatement stmt = null;
InputStream in = null;
OutputStream out = null;
BLOB blob = null;
ResultSet rs = null;
try {
newhua.dbbean  db=new newhua.dbbean();
     db.InitDatabase();
     conn =db.conn;
     //String filename;
     //filename="c:/tomcat/webapps/nw/lsdoc/o_"+sample+".sxw"; 
             String mysql="Select word FROM tmanuscript WHERE glidenumber ='"+sample+"' ";
System.out.println(mysql);

stmt = conn.prepareStatement(mysql);
//stmt.setString(1,"67");
rs = stmt.executeQuery();
if(rs.next()) {
blob = ((OracleResultSet)rs).getBLOB("word");

in = blob.getBinaryStream();
out = new FileOutputStream(filename);
int bufferSize = blob.getBufferSize();
byte[] buffer = new byte[bufferSize];
int bytesRead = 0;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
System.out.println(bytesRead);
}
                        stmt.clearParameters();
buffer = null;
in.close();
out.close();
conn.commit();
}
}

catch(Exception e) {
e.printStackTrace(); } finally {
try {



in = null;
blob = null;
rs = null;
out = null;
conn = null;
stmt = null;
}
catch(Exception e) { }
}  }
  
}jsp:<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.io.*,java.util.*,java.sql.*,java.text.*,oracle.jdbc.driver.*,oracle.sql.*" %><HTML><HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><link rel="STYLESHEET" type="text/css" href="css/style.css">
<TITLE>发文--保存</TITLE><script language="javascript">
</script>
</HEAD>
<jsp:useBean id="writeBeanId" scope="session" class="newhua.writeBean" />
<jsp:setProperty name="writeBeanId" property="*" /><BODY  BGCOLOR=#CCCCc2 TEXT=#0f0000 LINK=#0000ff ALINK=#cc0000 VLINK=#306898 TOPMARGIN=5 MARGINHEIGHT="5" >
<%!
public static String UnicodeToChinese(String s){
  try{
     if(s==null||s.equals("")) return "";
     String newstring=null;
     newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
     return newstring;
    }
  catch(UnsupportedEncodingException e)
  {
  return s;
  }
  }%>
<%
String glidenumber,comenumber,author,editor,buildtime,subject,flag;glidenumber=UnicodeToChinese(request.getParameter("glidenumber")) ;
comenumber=UnicodeToChinese(request.getParameter("comenumber")) ;
author=UnicodeToChinese(request.getParameter("author")) ;
editor=UnicodeToChinese(request.getParameter("editor")) ;
buildtime=UnicodeToChinese(request.getParameter("buildtime")) ;
subject=UnicodeToChinese(request.getParameter("subject")) ;
flag=UnicodeToChinese(request.getParameter("flag")) ;String mysql;
mysql="INSERT INTO SYSTEM.TMANUSCRIPT (COMENUMBER ,GLIDENUMBER ,AUTHOR ,FLAG ,EDITOR ,BUILDTIME,SUBJECT,WORD  )";
mysql=mysql+"  VALUES ('"+comenumber+"' ,'"+glidenumber+"' ,'"+author+"' ,'"+flag+"' ,'"+editor;
mysql=mysql+" ' ,'"+buildtime+" ' ,'"+subject+"' ,EMPTY_BLOB() )";out.println(mysql);
newhua.dbbean  db=new newhua.dbbean();
db.executeSql(mysql);String filename="c:/lsdoc/"+glidenumber+".sxw";
writeBeanId.setFilename(filename);
writeBeanId.setSample(glidenumber);
System.out.println(filename);
System.out.println(glidenumber);
writeBeanId.gwrite() ;response.sendRedirect("search.jsp");
%></BODY>
</HTML>
//重点是要导入oracle的包,其他都一样操作..