通常用法
InputStream is=getClass().getResourceAsStream("/db.properties")
把db.proerties放在 .....WEB-INF\classes\目录下
InputStream is=getClass().getResourceAsStream("/db.properties")
把db.proerties放在 .....WEB-INF\classes\目录下
解决方案 »
- Velocity 和 FreeMarker在并发情况下,哪个性能更好?
- 怎样将class文件打包成jar
- 很多分,Resin服务,中文页面出现“??”,怎么解决?
- 散分求助。一个捆饶我的问题,如何把radio的value值取出来,进者有礼,详情代码请入内
- (100分,回答全者给分多)HttpSession session = request.getSession(false);中的false是什么意思?
- jsp到serlet传值的问题
- applet调用第三方jar的方法时出错
- quartz---怎样获得已经停止的Scheduler
- 一个jsp学习过程中的简单问题
- 连接 sybase 的问题,来者给分!
- 大哥哥们 帮帮我呀!
- ##用javamail发送邮件,代码如下##
try{
//String iconfile=System.getProperty("user.dir");
in = getClass().getResourceAsStream("/sql.properties");
props.load(in);
}
catch (Exception e) {
System.err.println("读取sql.properties文件出错"
+ "in PlatformGlobals");
e.printStackTrace();
}
finally {
try {
if (in != null) { in.close(); }
} catch (Exception e) {}
}
if (props != null) {
sDBDriver = props.getProperty("driver"); //"sun.jdbc.odbc.JdbcOdbcDriver";
sConnStr = props.getProperty("url"); //"jdbc:odbc:myodbc";
user = props.getProperty("user");
password = props.getProperty("password");
if (sDBDriver ==null || sConnStr ==null || user ==null || password ==null) {
System.out.println("请检查sql.properties文件设置是否有误");
}
else{
try {
Class.forName(sDBDriver);
}
catch (java.lang.ClassNotFoundException e) {
System.err.println("mydb(): " + e.getMessage());
}
}
}