• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate config file

 
syruss kumar
Ranch Hand
Posts: 107
  • 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 .
 
R George
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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate 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.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
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: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot friends .I have corrected that error as per your suggestion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic