JDBC - DBCP连接池
作者:互联网
1 public class DBCPUtils { 2 3 /** 4 * DBCP数据库连接池 5 */ 6 private static DataSource source; 7 8 static { 9 try { 10 Properties pros = new Properties(); 11 FileInputStream is = new FileInputStream(new File("src/dbcp.properties")); 12 pros.load(is); 13 source = BasicDataSourceFactory.createDataSource(pros); 14 } catch (Exception e) { 15 16 } 17 } 18 19 public static Connection getConnection(){ 20 Connection conn = source.getConnection(); 21 return conn; 22 } 23 }
标签:JDBC,getConnection,pros,DBCP,source,static,FileInputStream,new,连接池 来源: https://www.cnblogs.com/yhc-love-cl/p/15069430.html