This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Madhuri Abhi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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.


 
Sudheer Bhat
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • 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
  • 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.

 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Include an URL to the file and the browser should automatically show you the file open/download box etc...
 
Juanjo Cuadrado
Greenhorn
Posts: 18
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • 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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic