com.bixuebihui.datasource.DruidDataSourceAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of c-dbtools Show documentation
Show all versions of c-dbtools Show documentation
a fast small database connection pool and a active record flavor mini framework
package com.bixuebihui.datasource;
import com.alibaba.druid.pool.DruidDataSource;
import com.bixuebihui.dbcon.DatabaseConfig;
/**
* DruidDataSourceAdapter class.
*
* @author xingwx
* @version $Id: $Id
*/
public class DruidDataSourceAdapter extends DruidDataSource implements INamingPool {
/**
*
*/
private static final long serialVersionUID = -3090433579721571673L;
/**
* getAlias.
*
* @return a {@link java.lang.String} object.
*/
@Override
public String getAlias() {
return getName();
}
/** {@inheritDoc} */
@Override
public void setAlias(String alias) {
this.setName(alias);
}
/** {@inheritDoc} */
@Override
public void setDatabaseConfig(DatabaseConfig cfg) {
this.setAlias(cfg.getAlias());
this.setDriverClassName(cfg.getClassName());
this.setUrl(cfg.getDburl());
this.setUsername(cfg.getUsername());
this.setPassword(cfg.getPassword());
this.setMaxActive(cfg.getMaxActive());
this.setMaxWait(cfg.getMaxWaitTime());
this.setMaxOpenPreparedStatements(cfg.getMaxOpenPreparedStatements());
this.setRemoveAbandoned(removeAbandoned);
this.setRemoveAbandonedTimeout(cfg.getMaxIdle());
//防止过期
this.setValidationQuery("SELECT 'x'");
this.setTestWhileIdle(true);
this.setTestOnBorrow(true);
}
}