Here enjoy it.

//code starts here.

import java.io.File;
 import java.io.FileInputStream;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
  
 public class PDFConnect
   {
    
 public static void main(String args[])
 {
 try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = 
DriverManager.getConnection("jdbcracle:thin:@10.81.7.169:1521TS", "TESTPTS", 
"TESTPTS");
 System.out.println("connection established");
 PreparedStatement ps = conn.prepareStatement("insert into DEMOBLOB values(?)");
 System.out.println("insert executed");
 File photo= new File("D:/Thinkingjava.pdf");
 System.out.println("image loaded ");
 FileInputStream photostream= new FileInputStream(photo);
 System.out.println("photo taken");
 ps.setBinaryStream(1,photostream,(int)photo.length());
 ps.executeUpdate();
 photostream.close();
  
 }
  
 catch(Exception e)
  {
 e.printStackTrace();
  }
  } 
 }

//code ends here

 

--- On Thu, 1/8/09, Miguel Angel Sereno <knul...@gmail.com> wrote:
From: Miguel Angel Sereno <knul...@gmail.com>
Subject: [java programming] Re: How to insert PDF files into oracle database
To: cartigay...@gmail.com
Cc: nand...@gmail.com, "Free Java Programming Online Training Course By Sang 
Shin" <javaprogrammingwithpassion@googlegroups.com>
Date: Thursday, January 8, 2009, 10:50 AM

hi all,

Try to convert the pdf in base64 and insert the code in a column in DB

greetings!!

On Wed, Jan 7, 2009 at 10:40 PM, cartigayane keingadarane 
<cartigay...@gmail.com> wrote:

Hi,

Try to do by inserting that as a binary object OR binary Large Object.(Blob).

I believe you can do that through this way.

Hope this helps.


On Wed, Jan 7, 2009 at 4:43 PM, nand <nand...@gmail.com> wrote:




I have requirement to insert a pdf document from client pc into oracle

database, any inputs on this

is greatly appreciated



nan





















      
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to