Showing posts with label BlobDomain. Show all posts
Showing posts with label BlobDomain. Show all posts

Tuesday, April 21, 2009

Create and Insert BLOB into Database using Java

This will Create BLOB Object For you
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc:oracle:thin:@d2.bs-cochin.com:1521:orcl", "scott", "tiger");
File = new File("D:\\ADF.pdf");
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bin=new BufferedInputStream(fis);
fblob =BLOB.createTemporary(con,true,BLOB.DURATION_SESSION);
BufferedOutputStream bout = new BufferedOutputStream(fblob.getBinaryOutputStream());
IOUtils.copy(bin,bout);
System.out.println("========BLOB======>"+fblob.length());
it also works in TOPLINK.