0

I have a method that creates PDFs and a servlet that uploads files to my database. Is there anyway I could directly upload the created PDFs to my database? I am using FileOutputStream to create my PDFs.

11
  • 2
    Might depend a bit on what kind of database you are using. Commented Mar 25, 2016 at 17:14
  • ? do u mean by directly Commented Mar 25, 2016 at 17:15
  • Hi Jane (if that is indeed your real name), you need to look at your database schema and find a binary object that can contain your PDF file. It might be a "BLOB" or something like that. Then you need to find a method in your db API that allows a file to be saved to that binary data type. Commented Mar 25, 2016 at 17:17
  • Exactly, 1st question is what database are you using. Then, there's quite a few questions on the subject already, this one is about sql-server, this one is a long discussion whether it is worth it to store files on the database. Anyhow, as it is formulated right now, this question is too broad. You'll get much more chances of an answer if you narrow it down. Commented Mar 25, 2016 at 17:18
  • I am gettings user's input and compiling them in a PDF so that I could make a file per user and store them in my database. Is there any way to create the PDF then store it in my database? Can I directly write my FileOutputStream to my database? I am using MS SQL SERVER. Commented Mar 25, 2016 at 17:19

1 Answer 1

1

Sounds like you need something like Java Caching System or Ehcache. Putting PDF's in a database is generally not a good idea, though it has certainly been done.

I suppose it depends on how long you expect the user to want to retrieve the file. If a long time, perhaps a database could have advantages because it is administered, backed up, etc. However, all the same things can be said about a file cache and if you have a lot of the files then you should have much happier system admins using a simple file store.

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.