时间:2021-07-01 10:21:17 帮助过:6人阅读
三、获取Connection对象
private static DataSource source;
//静态代码块 static { try { Properties pros=new Properties(); InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("druid.properties"); pros.load(is); source=DruidDataSourceFactory.createDataSource(pros); } catch (Exception e) { e.printStackTrace(); } }
//getConnection public static Connection getConnectionByDruid()throws Exception { Connection conn=source.getConnection(); return conn; }
JavaJDBC-使用数据库连接池技术(Druid)获取Connection对象
标签:配置文件 uid cti 参数 word 文件 username ini nec