• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using hibernate.cfg.xml

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this and it is giving me FileNotFoundException.

 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bosun,

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

Thanks
 
Bosun Bello
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to resolve the error, or post it here if you can't.
 
Bosun Bello
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to resolve the error, or post it here if you can't.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic