String
String

Reputation: 3728

jdbc connection from xml file

I am trying to read xml file in java.But I am facing FilenotFoundException .Could any one help?

Source Code:

Properties props = new Properties();
                FileInputStream fis;

                try {
                    fis = new FileInputStream("src/org/inbound/service/db/dbdetails_remedey.xml");
                    try {
                        props.loadFromXML(fis);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                } catch (FileNotFoundException e1) {
                    e1.printStackTrace();
                }

Exception:

java.io.FileNotFoundException: src\org\inbound\service\db\dbdetails_remedy.xml (The system cannot find the path specified)

Upvotes: 0

Views: 203

Answers (1)

Krzysztof Darasz
Krzysztof Darasz

Reputation: 91

You should load your file from your classpath. Use Object method getClass();

example : getClass().getClassLoader().getResource("foo.xml");

Upvotes: 1

Related Questions