springboot+dbcp数据库连接池
1,连接池配置文件
在resources目录下添加文件dbcp.properties文件
内容如下:
2,连接工具类
通过工具类去读取连接池的配置信息
3,测试类测试连接
调用工具类的连接方法,打印日志
4,实际调用连接去同步数据
Connection conn=null;
PreparedStatement st=null;
try {
String sql=‘这里自己的insert’;
conn= DataSourceUtil.getConnection4();
st = conn.prepareStatement(sql);
st.execute();
st.close();
conn.close();
} catch (Exception e) {
System.out.println(e);
}finally{
if(st!=null){
st.close();
}
if(conn!=null){
conn.close();
}
}