-2

In my project i have forder with database. When i move project to another directory my database url doesn't work. So, I want to create universal method for getting current project path for creating universal database url. I'm looking for a way to get path like this:

C:\Users\UserName\FolderName\ProjectName

Structure of my project: Structure screenshot

enter image description here

azro
  • 53,056
  • 7
  • 34
  • 70
  • After `ProjectName` there is several architecture possible, simple/maven/... so diffcult – azro May 14 '18 at 17:42
  • 1
    ya @Lutzi, is right , but it should be done in different way ` upload.path /home/../pathtothefile ` in web.xml and get the context path upload.path – parlad May 14 '18 at 17:46

1 Answers1

1

Generally, tying your database location to the location of your application, which typically ends up in a JAR, is not a good idea. Instead, figure out where you want to put your database and add a reference. If necessary, you can pass the location from the command line or from a PROPERTIES file. Note that the PROPERTIES approach runs into problems if you package your application in a JAR, as you then can't modify it.

Steve11235
  • 2,849
  • 1
  • 17
  • 18