I came across a problem where I was able to read property file for a Java project but when it was being deployed to tomcat as a war it was giving problem.
The code that worked is pasted below
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("db.txt");
If you are making it for a DBconnection class which you are using for DAO in your code. The DBconnection class will be static.
- Create a src folder and name it resources
- Put the property file there.
- In the code access it like this
If you are making it for a DBconnection class which you are using for DAO in your code. The DBconnection class will be static.
No comments:
Post a Comment