Hi all, I am using was5.1 and hibernate. Since I am using two different dbs, have configured two different .cfg.xml files - test1.cfg.xml and test2.cfg.xml. The problem is where do I place these files and how do I locate them programmatically for getting the config parameters ? I have placed them in web-inf/classes folder, and tried looking up using
but it throws FilenotfoundException....
Have tried various other combinations too....all are failing.... Any ideas please?
Hibernate just uses java.io to load the file like this I think. Remember that creating a file with the new File(filename) constructor doesn't behave like the classLoader.getResourceAsStream(String resourcename). The later will traverse the classpath looking for the resource, the former won't. So your config files need to be in the same folder as the class that is trying to load it (unless you supply an absolute path).
One way round this (which is acceptable since once you have configured your ORM layer it remains fairly static) is to actually configure it in code. i.e.