java内容
Properties props = Resources.getResourceAsProperties("jdbc.properties");
String url = props.getProperty("jdbc.url");
String driver = props.getProperty("jdbc.driverClass");
String username = props.getProperty("jdbc.username");
String password = props.getProperty("jdbc.password");
Class.forName(driver).newInstance();
Connection conn = (Connection) DriverManager.getConnection(url, username, password);
jdbc.properties文件内容
jdbc.driverClass = com.mysql.jdbc.Driver
jdbc.url = jdbc\:mysql\://127.0.0.1\:3306/LY?useUnicode\=true&characterEncoding\=UTF-8&zeroDateTimeBehavior\=convertToNull&allowMultiQueries\=true
jdbc.username = root
jdbc.password = root
jdbc.minPoolSize=2
jdbc.maxPoolSize=20
jdbc.checkoutTimeout=3000
jdbc.maxStatements=50
jdbc.testConnectionOnCheckin = false
jdbc.idleConnectionTestPeriod =18000