-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: How to read hibernate db configuration from external file
PostPosted: Wed May 09, 2007 3:50 am 
Newbie

Joined: Mon Feb 14, 2005 10:11 am
Posts: 10
Location: Italy
Hi at all.
I'm a new user of hibernate and I'm trying to deploy my first application.
Everything work in Eclipse, but when I try to simulate an installation on a customer pc the first question that I have in mind is:
Is there a way to read configuration file hibernate.cfg.xml from file system instead of read it from the classpath?

This question is very important because I need to deploy the application in differente environment so the connection.url, connection.username, connection.password need to be editable.....

I didn't find topic about this problem....

Help me
Bye bye

_________________
Ing. Marco Rinaldi - Italy


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 09, 2007 9:08 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
Hi marcobazza,
configure via a File object located in the File System.
e.g.:
Code:
File file = new File("/my/absolute/path/hibernate.cfg.xml") ;
SessionFactory sessionFactory = new Configuration().configure(file).buildSessionFactory();

hope this helps

_________________
chucky

Don't forget to rate if this helps
-----------------------------------


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 09, 2007 9:30 am 
Newbie

Joined: Mon Feb 14, 2005 10:11 am
Posts: 10
Location: Italy
It works fine, now I've to map this method in a bean session factory for Spring, but this is easy.

Thanks you

_________________
Ing. Marco Rinaldi - Italy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.