此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【xm521】截止到2008-07-26 01:55:47的历史汇总数据(不包括此帖):
发帖的总数量:0                        发帖的总分数:0                        每贴平均分数:0                        
回帖的总数量:1                        得分贴总数量:0                        回帖的得分率:0%                       
结贴的总数量:0                        结贴的总分数:0                        
无满意结贴数:0                        无满意结贴分:0                        
未结的帖子数:0                        未结的总分数:0                        
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html

解决方案 »

  1.   

    import java.sql.*;
    import java.io.*;public class SavePicture{
    public static void main(String[] args){
    Connection conn = null;
        PreparedStatement stmt = null;
        FileInputStream fis = null;
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    String url = "jdbc:oracle:thin:@localhost:1521:ora9";
    conn = DriverManager.getConnection(url, "scott","tiger");
    String sql = "insert into Student_List values(?,?,?)";
    stmt=conn.prepareStatement(sql);
    stmt.setString(1,"s01");
    stmt.setString(2,"Youyou");
    File file = new File("yy.jpg");
                fis = new FileInputStream(file);
                stmt.setBinaryStream(3, fis, (int)file.length());
    stmt.executeUpdate();
    stmt.close();
    }catch(Exception e){
    e.printStackTrace();
    }finally{
        try{
            if(fis!=null){
             fis.close();
            }
        }catch(IOException ioe){
            ioe.printStackTrace();
        }
    try{
    if(conn != null){
    conn.close();
    }
    }catch(Exception e){
         e.printStackTrace();
    }
    }
    }
    }