This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Upload file and store it in database Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Upload file and store it in database" Watch "Upload file and store it in database" New topic
Author

Upload file and store it in database

Sri Gnana
Ranch Hand

Joined: Apr 29, 2004
Posts: 166
Hi,
Now i'm able to upload the file and store it in server, but i wanna store it in database, please give me an idea and url for reference.


Thanks & Regards
Sri Gnana
Everythings Programmed!...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have a look at the interfaces java.sql.Clob and java.sql.Blob, then have a look at the setBinaryStream(int parameterIndex, InputStream x, int length) method of java.sql.PreparedStatement class. You should be able to work it out from there.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56202
    
  13

Moving to the JDBC forum.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Sri GS
Greenhorn

Joined: Apr 29, 2004
Posts: 3
Thanks
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
There are 2 ways to do that

1 - Store the path of the file in Database and then display the image using that path. It will be efficient and your database size will reasonably reduce.
2 - Store the actual image in database in the form of bytes and then read those bytes and make a file and then display that in your page. This technique is more reliable as compare to 1st because if path of the files changes or any file get deleted then there will raise problems.

Its all depends on your requirements.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Upload file and store it in database
 
Similar Threads
File object
How to store/retrive images from database
Upload attachment using Java
how to upload file along with HTML form data
Using commons-fileupload-1.2.1.jar to upload file to MySQL