package com.yanek.base.database;
import java.io.InputStream;
import java.util.Properties;
public class ConfigUtil
{
private static Properties prop=new Properties();
private static boolean isLoaded=false;
public ConfigUtil()
{
}
public static Properties getConfigInfo()
{
return prop;
}
static
{
if (!isLoaded)
{
try
{
//InputStream is=new ConfigUtil().getClass().getResourceAsStream("RequestAndHandler.properties");
// InputStream is=new ConfigUtil().getClass().getResourceAsStream("db.properties");
//InputStream is= getServletContext().getResourceAsStream("/WEB-INF/db.properties");
// InputStream is=new ConfigUtil().getClass().getClassLoader().getResourceAsStream("com/yanek/db/db.properties");
// InputStream is=new ConfigUtil().getClass().getClassLoader().getResourceAsStream("com/yanek/db/dbconfig.properties");
// InputStream is=new ConfigUtil().getClass().getResourceAsStream("dbconfig.properties");
// InputStream is=new ConfigUtil().getClass().getClassLoader().getResourceAsStream("db.properties");
InputStream is=new ConfigUtil().getClass().getClassLoader().getResourceAsStream("db.properties");
prop.load(is);
isLoaded=true;
}
catch(java.io.IOException ex)
{
isLoaded=false;
ex.printStackTrace();
}
}
}
public static String getClassName(String ywdm)
{
String classname=(String)getConfigInfo().get(ywdm);
return classname;
}
public static void main(String[] args)
{
String url=(String)ConfigUtil.getConfigInfo().get("url");
System.out.println("url="+url);
String driver=(String)ConfigUtil.getConfigInfo().get("driver");
System.out.println("driver="+driver);
String user=(String)ConfigUtil.getConfigInfo().get("user");
System.out.println("user="+user);
String password=(String)ConfigUtil.getConfigInfo().get("password");
System.out.println("password="+password);
}
}