• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

can anybody tell me how to upload a file(txt or doc or pdf)into database through java

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to All,

I am praveen,can anybody help me in uploading a file through java.



with regards
praveen CH
 
Sheriff
Posts: 22683
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Use a PreparedStatement for your insert query.
2) Get an InputStream or Reader from the File
3) Use the PreparedStatement's most appropriate setXXX method.
4) executeUpdate() the PreparedStatement
5) close() the PreparedStatement
6) close() the InputStream or Reader from step 2

Words in capitals indicate the class to look for.
Words with () behind them indicate the method to use.

As for the most appropriate setXXX method, setAsciiStream or setCharacterStream are good options for character data (text files), whereas for DOC or PDF you'd want to store them in binary form, using setBinaryStream.
[ March 10, 2008: Message edited by: Rob Prime ]
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Praveen,

In addition to that you will have to define a column in your database table of type BLOB which will store the document in binary form.

Thanks,
Suraj
 
What's gotten into you? Could it be this tiny ad?
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic