How to store doc, jpeg, pdf files in postgreSQL using java

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

  • What should be the data type for the table.
  • Does it support document formatting?
  • And how to save it in postgreSQL is possible using java, hibernate technology. Is nativeSQL required to create a query?

Any pointers to this problem would be helpful.

+4
source share
1 answer

You want to save binary data as a bytea type. Here is an example of using JDBC and Postgres bytea :

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

This post about using bytea and Hibernate might be helpful: proper hibernation annotation for byte []

+8
source

All Articles