• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

derby and hibernate db relative path question

 
jim mcnamara
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi-

i have a hibernate.cfg.xml and a hibernate.properties file.
how can i either make it so hibernate.cfg.xml or hibernate.properties
reside outside the fatjar directory structure so a user can edit them
to point to their choice of db install location (this would be cool)

OR

better yet, is there a way to make it so it is coded so that
the user doesnt have to edit those files? (even cooler)

i can do this with other file types i.e. txt,jasper,gif, but it is because they are referred to from
java source files and not configuration files. i get a system property
that gives the current directory and then append the child directory.

thanks for any assistance,
jim
 
jim mcnamara
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi-

i think i may have came across an idea i pieced together searching.
i set a classpath in java using:
export CLASSPATH=$CLASSPATH:/home/thirdshift/demolib
i can add this with the java -jar demorun_fat.jar
in a .sh file.

and in my hibernate.cfg.xml file there is this :

AnnotationConfiguration cfg = new AnnotationConfiguration();
String userDir = System.getProperty("user.dir");
cfg.configure(new File(userDir+"/hibernate.cfg.xml"));

sessionFactory = cfg.buildSessionFactory();

so now derby is embedded but the db files are outside of the jar
which makes sense (to do it that way)

so the user may have a little bit of configuration for now.
if they know any xml at all it wont be bad.

i will have to provide them with documentation.

i hope i got this right and don't confuse anyone (if not).
now i can finish testing, write a configuration help file,
and upload.

thanks,
jim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic