Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using hibernate.cfg.xml

 
Purohit Punam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to use alternate hibernate.cfg.xml from two available hibernate.cfg.xml files. I have created properties file two select the database.

My properties file is lying in src folder, I have problem reading properties file


It is giving me FileNotFoundException if i write physical path for properties file it works fine but for above path it does not. can any one help why am i getting this error for properties file.

Thanks,
Punam
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Punam,

So, what is requirement. If your project contains two hibernate.cfg.xml and you want to configure it refer below link

Configuration.

Or

According to property file given path you want to select hibernate.cfg.xml ?

Still give some more information if I was wrong ...
 
Purohit Punam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nishan

I have properties file and i want to get the value of properties file in my HibernateSessionFactory java class.
For accessing properties file i have to give physical path starting from
d:\\...
,

properties file is in src folder of my application.

I want to access it using "dbConnection.properties" file name not any physical path. because it may cause problem at deployment time.

Did you get it or need more specification?

 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

this topic discuss at java ranch before... read this ... Read Properties File

 
Purohit Punam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this and it is giving me FileNotFoundException.

 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use getResource or getResourceAsStream methods. Try this:



Purohit Punam wrote:I tried this and it is giving me FileNotFoundException.

 
Purohit Punam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bosun,

I tried this and it is giving me compile time error.

Thanks
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to resolve the error, or post it here if you can't.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to resolve the error, or post it here if you can't.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic