package com.kevin.Utils;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
public class DBTools {
//创建BasicDataSource对象
private static BasicDataSource datasource = new BasicDataSource();
//静态代码块,实现必要参数设置
static{
datasource.setDriverClassName("com.mysql.jdbc.Driver");
datasource.setUrl("jdbc:mysql://localhost:3306/test");
datasource.setUsername("root");
datasource.setPassword("123");
datasource.setMaxActive(10);
datasource.setMaxIdle(5);
datasource.setMinIdle(2);
datasource.setInitialSize(10);
}
public static DataSource getDataSource(){
return datasource;
}
}