I am creating a jar using hibernate. I have encountered a situation where I need to change a setting (url) often, so I would like to load the hibernate.cfg.xml
like
There is a method public Configuration configure(File configFile)
in class Configuration
Try the following, it should work for sure :)
File f = new File("D:\\fax\\hibernate.cfg.xml");
SessionFactory sessionFactory = new Configuration().configure(f).buildSessionFactory();
The difference is you have used a method configure(String resource)
which is expecting a resource in a classpath, but where as configure(File configFile)
is expecting a File
, so you can pass it.