Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.file;
- import java.io.FileOutputStream;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import oracle.sql.BLOB;
- public class FileDownload {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- try
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","kannan","test123");
- Statement st=con.createStatement();
- ResultSet rs=st.executeQuery("select * from kannan1");
- rs.next();
- System.out.println(rs.getString(1));
- BLOB blop=(BLOB) rs.getBlob(2);
- byte data[]=blop.getBytes(1,(int) blop.length());
- FileOutputStream fout=new FileOutputStream("d:\\kannan1.pdf");
- fout.write(data);
- System.out.println("File Download Successfully");
- }catch(Exception e)
- {
- System.out.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement