日期:2014-05-20 浏览次数:20824 次
/*TestProperties*/ import java.util.Properties; import java.util.Enumeration; public class TestProperties { public static void main(String[]args) { Properties props=System.getProperties(); Enumeration prop_names=props.propertyNames(); while(prop_names.hasMoreElements()) { String prop_name=(String)prop_names.nextElement(); String property=props.getProperty(prop_name); System.out.println("属性:"+prop_name+"'是"+property+"'"); } } }
private ConnectionFactory() { Properties prop = null; try { InputStream in = this.getClass().getClassLoader() .getResourceAsStream("properties/dbconfig.properties"); prop = new Properties(); prop.load(in); driver = prop.getProperty("driver"); dbURL = prop.getProperty("url"); user = prop.getProperty("user"); password = prop.getProperty("password"); in.close(); } catch (Exception e) { System.out.println("No dbconfig.properties defined error"); System.exit(-1); } }