Link to home
Start Free TrialLog in
Avatar of ethnarch
ethnarch

asked on

Hibernate XML Configuration file and application path

I am using firebird's embedded database(or trying to atleast) with my application.  I want to be able to set the path to the database relative to my application for instance normally outside of hibernate i could do something like this:

String dir = System.getProperty("user.dir");
            Connection con = null;
            Driver d = (Driver)Class.forName( "org.firebirdsql.jdbc.FBDriver" ).newInstance();
            con = DriverManager.getConnection("jdbc:firebirdsql:embedded:" +dir + "\\USERDB.FDB", "sysdba", "masterkey");

I can't figure out how i would get hibernate to recognize the working directory of the application in it's xml configuration file I would like to do something similar to below where %ApplicationDIR% would be the application directory.  Is this possible?

<property name="hibernate.connection.url">jdbc:firebirdsql:embedded:%ApplicationDIR%USERDB.FDB</property>
     
           
ASKER CERTIFIED SOLUTION
Avatar of Ajay-Singh
Ajay-Singh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ethnarch
ethnarch

ASKER

i actually figured it out, ehh it was pretty simple all i had to do was put

<property name="hibernate.connection.url">jdbc:firebirdsql:embedded:USERDB.FDB</property>

I will try your idea later Ajay and i'll just give you both points for helping thanks anyway though.