0

I currently use a SQLite database and the location of this one is hardcoded which is very bad practice and would force me to rebuild the war file every time I want to deploy it to a different server.

I've been thinking of using a relative path to the application directory by using servletContext.getRealPath() but it seems to be a problem when I want to do it that way with a crontab job (Quartz) since I cannot get a FacesContext.

Is it possible to somehow specify the location of the database during the deployment and store it somewhere or is there any other solution?

Uric34
  • 9
  • 3
  • Whilst the question is from a completely different perspective, the answer is basically exactly the one you're looking for: http://stackoverflow.com/questions/18664579/recommended-way-to-save-uploaded-files-in-a-servlet-application Is this perhaps acceptable as dupe? – BalusC Aug 15 '15 at 13:50
  • Thank you @BalusC, That's exactly what I was looking for. I think I'll use VM arguments although property files seems interesting too but the configuration would be lost if we edit the the property then redeploy, right? – Uric34 Aug 15 '15 at 14:27
  • As to editable properties files, you'll need an external configuration for its location anyway :) http://stackoverflow.com/questions/2161054/where-to-place-and-how-to-read-properties-files-in-a-jsp-servlet-web-application – BalusC Aug 15 '15 at 16:39

0 Answers0