读取web-inf里的文件
String userName = " " ;
String userPassWord = " " ;
String driver = " " ;
String url = " " ;
private Properties props = new Properties();
public remoteDBFactory()
{
try
{
InputStream is = getClass ().getClassLoader ().getResourceAsStream ( "/remotejdbc.properties ") ;
props.load (is) ;
userName = props.getProperty ( "userName ") ;
userPassWord = props.getProperty ( "userPassWord ") ;
driver = props.getProperty ( "driver ") ;
url = props.getProperty ( "url ") ;
}
catch (Exception e)
{
System.out.println(e);
}
}

本文详细介绍了如何使用Java读取web-inf目录下的properties文件,从中获取远程数据库的用户名、密码、驱动和URL等关键信息,并进行数据库连接配置。
2826

被折叠的 条评论
为什么被折叠?



