|
public class BlobTest {Connection conn= null;Statement st = null;ResultSet rs=null;public void test(){conn = Conn.getConnection();try {st = conn.createStatement();rs = st.executeQuery("select * from OFFICE_WORKFLOWATTACHMENT");while (rs.next()){String name = rs.getString("ATTACHMENT_NAME");Blob blob = rs.getBlob("ATTACHMENT_CONTENT");if(blob!=null && blob.length()>0){FileOutputStream fout;try {fout = new FileOutputStream("c:/"+name);try {fout.write(blob.getBytes(1, (int)blob.length()));fout.flush(); fout.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();} } catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();}} }rs.close(); st.close(); conn.close();} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}} |
|