读取properties文件
InputStream in = getClass().getClassLoader().getResourceAsStream("jdbc.properties"); Properties properties = new Properties(); properties.load(in); driverClass = properties.getProperty("driver"); jdbcURL = properties.getProperty("url"); user = properties.getProperty("user"); password = properties.getProperty("password");
peoperties配置文件的格式
driver=com.mysql.jdbc.Driver url=jdbc:mysql://127.0.0.1:3306/test user=root password=123