• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Hibernate config file

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have created a simple java application to read the username and password from the database using hibernate.i have created all necessary files to fetch the records from database .while im trying to run the application i got the error.

cannot find hibernate.cfg.xml.

I have kept the cfg.xml file in src folder.im really confused where to place the hibernate.cfg.xml file.
Can any one suggest me where to place the cfg.xml file in a java application.

Thanks in advance .
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to keep the hibernate config file within your classpath. In your application, keep it outside the src folder.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In your application, keep it outside the src folder.


Ehm, did you mean to keep it inside the src folder? Most IDEs will copy everything in there other than java files into the classpath.
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Paul said, it needs to be on the classpath. Look at where your class files go when you deploy, and that's probably the folder you need your config file.

Build scripts move compiled Java code into bin or classpath directories. They don't always move xml and text files. Make sure the hibernate config file is actually in your classpath or build or bin directory, or whatever you have it named. Otherwise, you won't be able to find it at runtime.

-Cameron McKenzie
 
syruss kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot friends .I have corrected that error as per your suggestion.
 
Tell me how it all turns out. Here is a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic