• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

file upload using java

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to upload a file(either txt or doc. file) into database using core java. I had made a simple swing programe. I just want to browse to particular file and upload it to database.

can anyone provide me a starter tips regarding this.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Getting the file contents is just basic usage of the java.io package, probably involving a FileDialog or JFileChooser. The upload can be handled by the Jakarta HttpClient library, while the server part is handled by the Jakarta FileUpload library. Links to both can be found in this FAQ page: http://faq.javaranch.com/java/FileUpload (That's assuming you want to use HTTP for the upload. The page also talks about other protocols.)
 
Sheriff
Posts: 22783
131
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
Well Ulf, it is a Swing program, so the JFileChooser would be enough for selecting the file.

If you look at PreparedStatement, it has methods to set the value as a binary stream.

So to input one field would be something like this:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic