----db.properties-------- dbDriver = oracle.jdbc.driver.OracleDriverurl = jdbc:oracle:thin:@192.168.1.186:1521:jfglorcluserName=jfglpassword=jfgl ------------ JDBConnection ---------------------------- public class JDBConnection { public Connection…
public class PropertyUtil { public static final Properties PROP = new Properties(); /** * 读取配置文件的内容(key,value) * * @param key * @return key对应的value */ public static String get(String key) { if (PROP.isEmpty()) { try { InputStream in = PropertyUtil.cl…
若是Javaweb项目,项目运行于tomcat或其他容器时,可以使用下面方式来获取文件的输入流 1.当属性文件放在src下面时 InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("test.properties"); Properties p = new Properties(); p.load(is); 2.当属性文件放在某个包下面时,如:com.test.confi…
Properties prop = new Properties(); prop.load(this.class.getClassLoader().getResourceAsStream("path")); url = prop.getProperty("jdbc_url"); name = prop.getProperty("className"); user = prop.getProperty("jdbc_username&quo…