public static Connection getConnection() throws SQLException, IOException {
Properties props = new Properties();
String fileName = "GetDb.properties";
FileInputStream in = new FileInputStream(fileName);
props.load(in); 请问各位大侠,ViewDB.properties这个文件应该放在哪个路径下面呢?我试了放在SRC下面不行,总是提示该文件无法找到,谢谢了。
Properties props = new Properties();
String fileName = "GetDb.properties";
FileInputStream in = new FileInputStream(fileName);
props.load(in); 请问各位大侠,ViewDB.properties这个文件应该放在哪个路径下面呢?我试了放在SRC下面不行,总是提示该文件无法找到,谢谢了。
到底是ViewDB.properties还是GetDb.properties
-com.your.pkg
-your.java
-xxx.properties
your.class.getResourceAsStream("xxx.properties");
try
{
props.load(new FileInputStream(fileName ));
}
catch (Exception ce)
{
ce.printStackTrace();
}
public static Connection getConnection() throws SQLException, IOException {
Properties props = new Properties();
String fileName = "GetDb.properties";
FileInputStream in = new FileInputStream(fileName);
props.load(in);
这么写的话,文件应该放到class文件同级目录才行吧?要么就像楼上写绝对路径去
props.load(is);