6

In a web application I want to store all doc, jpeg, pdf files in postgreSQL database. I know it can also be done by storing it on file system and storing its path in db, but I am not looking for that solution. I want to know following things:

  1. What should be data type for a table.
  2. Does it maintain formatting of doc ?
  3. And how storing it in postgreSQL can be achieved using java, hibernate technology. IS it required to create nativeSQL query?

Any pointers for this issue will be helpful.

1 Answer 1

10

You'll want to store the binary data as the bytea type. Here is an example using JDBC and Postgres bytea:

http://jdbc.postgresql.org/documentation/80/binary-data.html

This post about using bytea and Hibernate might be of some use: proper hibernate annotation for byte[]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.