cn.hutool.db.ds.simple.SimpleDSFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hutool-all Show documentation
Show all versions of hutool-all Show documentation
Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。
package cn.hutool.db.ds.simple;
import cn.hutool.db.ds.AbstractDSFactory;
import cn.hutool.setting.Setting;
import javax.sql.DataSource;
/**
* 简单数据源工厂类
*
* @author Looly
*
*/
public class SimpleDSFactory extends AbstractDSFactory {
private static final long serialVersionUID = 4738029988261034743L;
public static final String DS_NAME = "Hutool-Simple-DataSource";
public SimpleDSFactory() {
this(null);
}
public SimpleDSFactory(Setting setting) {
super(DS_NAME, SimpleDataSource.class, setting);
}
@Override
protected DataSource createDataSource(String jdbcUrl, String driver, String user, String pass, Setting poolSetting) {
SimpleDataSource ds = new SimpleDataSource(//
jdbcUrl, //
user, //
pass, //
driver//
);
ds.setConnProps(poolSetting.getProps(Setting.DEFAULT_GROUP));
return ds;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy