JDBC10 Blob binary object

             // pictures entered into the database
 //             String SQL = "INSERT INTO t_user2 (username, headImg) values (,??)";
 //             PS = conn.prepareStatement (SQL);
 //             ps.setObject (1, 2 );
 //             ps.setBlob (2, new new the FileInputStream ( "D: /img.png"));
 //             ps.execute (); 
            
            // read the image into sub-program out 
            String sql = "select * from WHERE ID = t_user2 "? ; 
            PS = conn.prepareStatement (SQL); 
            ps.setObject ( . 1,. 3 ); 
            RS = ps.executeQuery ();
             the while (rs.next ()) { 
            Blob B=rs.getBlob("headImg");
             is=b.getBinaryStream();
            byte[] temp=new byte[1024*10];
            int len;
            os=new FileOutputStream("d:/imgcopy");
            while((len=is.read(temp))!=-1){
                os.write(temp, 0, len);
            }

 

Guess you like

Origin www.cnblogs.com/code-fun/p/11443674.html