• 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

Upload file or pdf in database with its extension in separate column

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

I want to upload either image or pdf or doc files(etc) in database with its extension.
Say suppose if i upload an text file, its extension .txt should be stored in one of the columns. How can i do that?

Thanks,
Madhuri.


 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
store the file as BLOB and the extension as varchar column in the table? You just need to strip off the extension and store it in the varchar column. Not really sure why you want to store the file extension though.
 
Madhuri Abhi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am able to store files in the database. The fields in the database are id, name( of the file as varchar), type(file extension as varchar) and content(as blob).

While retrieving from database, i want to display just the id, name and extension in jsp page in table form. That can be done very easily.

But what i want to do is when the name(that is displayed) is clicked, the file should open. any idea on how i can do that.

 
Ranch Hand
Posts: 312
MS IE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Include an URL to the file and the browser should automatically show you the file open/download box etc...
 
Greenhorn
Posts: 18
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Your cuestion I think is about servlet, not JDBC.

If you want to open file doing click over a link, you have to have a servlet, and in the get (or post) method put this code (or another similar):



I hope this help you...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic