`
Sharpleo
  • 浏览: 565721 次
  • 性别: Icon_minigender_1
  • 来自: newsk
社区版块
存档分类
最新评论

Java加载src目录下Properties文件

    博客分类:
  • java
 
阅读更多


package com.kingzheng.jztag.dao;

import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;
/**
 * 
 * @author kingschan
 * @date 2012-11-28
 * @description 查询方案操作的数据源连接
 */
public class QuerySavingConn implements AbstractConnection{

	@Override
	public Connection getConnection() throws Exception {
		 InputStream stream=Thread.currentThread().getContextClassLoader().getResourceAsStream("QueySaving.properties");
		 Properties properties=new Properties();
         properties.load(stream);
         System.out.println("Class:"+properties.getProperty("className"));
         System.out.println("userName:"+properties.getProperty("userName"));
         System.out.println("userPass:"+properties.getProperty("userPass"));
         System.out.println("connStr:"+properties.getProperty("connStr"));

		return null;
	}
	
	public static void main(String[] args) {
		try {
			new QuerySavingConn().getConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics