HOW TO Upload files to db (postgres) using java/jdbc
Joined: Jun 12, 2008
Hi, I am new to this and i want to upload some files to my database but i simple can't figure out how to...can anyone give me an example on how to upload a file(binary data) using java and jdbc to my database... Thank you Eduardo
By "upload", do you mean to store it as a whole? If so, that's what BLOB type attribute are for. That's supported by the Statement and ResultSet classes, so if you have the file contents in your Java code, it shouldn't be too difficult. What do you have so far?
As an aside, storing binary file contents in a DB isn't always the best way to do it. Have you considered storing the file in the file system, and only keeping the path to the file in the DB?