java.lang.NullPointerException at java.util.Properties$LineReader.readLine(Properties.java:418)
at java.util.Properties.load0(Properties.java:337)
at java.util.Properties.load(Properties.java:325)
at monitor.util.DBConnection.<clinit>(DBConnection.java:30)
here line 30 is: databaseProperties.load(DBConnection.class.getClassLoader().getResourceAsStream("dbInfo.properties"));
Any suggestion how to avoid the above exception ?
The dbInfo.properties file is alreay present at the location where this DBconnection.java file is available.
Well, at runtime, the dbInfo.properties file needs to be where the DBConnection.class file is, not the .java file. If you're building and running this from an IDE, it can be tricky making sure all your bits are in the right place when you run the program. If you're packing this code into a JAR file, then the properties file needs to go into that JAR as well.
Thank you Ernest.
Actually had kept in folder where I had the DBConnection.class file. but while I moved to the out of that folder and kept inside Class folder (that is 1 level up), it works fine now
In your code you're using dbInfo.properties, while the file is called vectorDB.properties.
Also, the properties file is not located in the same folder (or a subfolder) as the class file, so you should try using an absolute path: /vectorDB.properties.