簡體   English   中英

xml文件的jdbc連接

[英]jdbc connection from xml file

我正在嘗試讀取java中的xml文件。但是我正面臨FilenotFoundException。有人可以幫忙嗎?

源代碼:

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();
                }

例外:

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

您應該從類路徑加載文件。 使用Object方法getClass() ;

示例: getClass().getClassLoader().getResource("foo.xml") ;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM