标签:XML asi word new artifact enc pid 创建 size
可以自行下载jar包,推荐使用maven自动获取。

pom.xml
<dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency>
public class JDBCUtil {
private static BasicDataSource ds =null;
static {
//创建数据库连接池对象
ds = new BasicDataSource();
//设置数据库连接信息
ds.setDriverClassName(driver);
ds.setUrl(url);
ds.setUsername(username);
ds.setPassword(password);
//设置初始连接数量
ds.setInitialSize(3);
//设置最大连接
ds.setMaxActive(5);
}
public static Connection getConnection() {
Connection conn = null;
try {
//从连接池获取连接对象
conn = ds.getConnection();
System.out.println(conn);
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}
标签:XML asi word new artifact enc pid 创建 size
原文地址:https://www.cnblogs.com/Scorpicat/p/12341166.html