本文整理匯總了Java中com.alibaba.druid.pool.DruidDataSource.setDriverClassName方法的典型用法代碼示例。如果您正苦於以下問題:Java DruidDataSource.setDriverClassName方法的具體用法?Java DruidDataSource.setDriverClassName怎麽用?Java DruidDataSource.setDriverClassName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.alibaba.druid.pool.DruidDataSource
的用法示例。
在下文中一共展示了DruidDataSource.setDriverClassName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
/**
* 初始化操作
*
* @param modelName 模塊名稱
* @param txConfig 配置信息
*/
@Override
public void init(String modelName, TxConfig txConfig) {
dataSource = new DruidDataSource();
final TxDbConfig txDbConfig = txConfig.getTxDbConfig();
dataSource.setUrl(txDbConfig.getUrl());
dataSource.setDriverClassName(txDbConfig.getDriverClassName());
dataSource.setUsername(txDbConfig.getUsername());
dataSource.setPassword(txDbConfig.getPassword());
dataSource.setInitialSize(txDbConfig.getInitialSize());
dataSource.setMaxActive(txDbConfig.getMaxActive());
dataSource.setMinIdle(txDbConfig.getMinIdle());
dataSource.setMaxWait(txDbConfig.getMaxWait());
dataSource.setValidationQuery(txDbConfig.getValidationQuery());
dataSource.setTestOnBorrow(txDbConfig.getTestOnBorrow());
dataSource.setTestOnReturn(txDbConfig.getTestOnReturn());
dataSource.setTestWhileIdle(txDbConfig.getTestWhileIdle());
dataSource.setPoolPreparedStatements(txDbConfig.getPoolPreparedStatements());
dataSource.setMaxPoolPreparedStatementPerConnectionSize(txDbConfig.getMaxPoolPreparedStatementPerConnectionSize());
this.tableName = RepositoryPathUtils.buildDbTableName(modelName);
executeUpdate(SqlHelper.buildCreateTableSql(tableName, txDbConfig.getDriverClassName()));
}
示例2: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(initMethod = "init", destroyMethod = "close")
public DruidDataSource dataSource(DruidConfig druidConfig) throws IOException {
DruidDataSource ds = new DruidDataSource();
ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
ds.setUrl(druidConfig.getUrl() + "?" + druidConfig.getOptions());
ds.setUsername(druidConfig.getUser());
ds.setPassword(druidConfig.getPwd());
ds.setInitialSize(druidConfig.getInitialSize());
ds.setMinIdle(druidConfig.getMinIdle());
ds.setMaxActive(druidConfig.getMaxActive());
ds.setMaxWait(druidConfig.getMaxWait());
ds.setTimeBetweenEvictionRunsMillis(druidConfig.getTimeBetweenEvictionRunsMillis());
ds.setMinEvictableIdleTimeMillis(druidConfig.getMinEvictableIdleTimeMillis());
ds.setValidationQuery(druidConfig.getValidationQuery());
ds.setTestWhileIdle(druidConfig.getTestWhileIdle());
ds.setTestOnBorrow(druidConfig.getTestOnBorrow());
ds.setTestOnReturn(druidConfig.getTestOnReturn());
return ds;
}
示例3: logDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(initMethod = "init", destroyMethod = "close")
public DruidDataSource logDataSource() throws SQLException, DESException {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(dbConfigProperties.getDriveClass());
druidDataSource.setUrl(dbConfigProperties.getLogUrl());
druidDataSource.setUsername(dbConfigProperties.getLogUsername());
druidDataSource.setPassword(dbConfigProperties.getLogPassword());
druidDataSource.setInitialSize(dbConfigProperties.getInitialSize());
druidDataSource.setMinIdle(dbConfigProperties.getMinIdle());
druidDataSource.setMaxActive(dbConfigProperties.getMaxActive());
druidDataSource.setMaxWait(dbConfigProperties.getMaxWait());
druidDataSource.setTimeBetweenEvictionRunsMillis(dbConfigProperties.getTimeBetweenEvictionRunsMillis());
druidDataSource.setMinEvictableIdleTimeMillis(dbConfigProperties.getMinEvictableIdleTimeMillis());
druidDataSource.setValidationQuery(dbConfigProperties.getValidationQuery());
druidDataSource.setTestWhileIdle(dbConfigProperties.getTestWhileIdle());
druidDataSource.setTestOnBorrow(dbConfigProperties.getTestOnBorrow());
druidDataSource.setTestOnReturn(dbConfigProperties.getTestOnReturn());
druidDataSource.setPoolPreparedStatements(dbConfigProperties.getPoolPreparedStatements());
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(dbConfigProperties.getMaxPoolPreparedStatementPerConnectionSize());
druidDataSource.setFilters(dbConfigProperties.getFilters());
return druidDataSource;
}
示例4: buildDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
/**
* 通過基礎配置信息構建Druid數據源信息.
* @param driver 數據庫連接的JDBC驅動
* @param url 數據庫連接的url
* @param user 數據庫連接的用戶名
* @param password 數據庫連接的密碼
*/
public DruidDataSource buildDataSource(String driver, String url, String user, String password) {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(driver);
dataSource.setUrl(url);
dataSource.setUsername(user);
dataSource.setPassword(password);
return dataSource;
}
示例5: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean //聲明其為Bean實例
@Primary //在同樣的DataSource中,首先使用被標注的DataSource
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
//configuration
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
logger.error("druid configuration initialization filter", e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}
示例6: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean
@Primary
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(url);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
//configuration
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
System.err.println("druid configuration initialization filter: " + e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}
示例7: init
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
public void init() throws Exception{
System.out.println("**************init");
MicroMetaDao dao=MicroMetaDao.getInstance();
String sql="select * from nh_micro_dbconf";
List<Map<String,Object>> infoList=dao.queryObjJoinByCondition(sql);
for(Map<String,Object> row:infoList){
String metaKey=(String) row.get("meta_key");
String dataSourceClassName=(String) row.get("datasource_classname");
String dbUser=(String) row.get("db_user");
String dbPassWord=(String) row.get("db_password");
if(dbPassWord.startsWith("nhjm-")){
String temp=dbPassWord.substring(5);
dbPassWord=DESUtil.decrypt(temp);
}
String dbUrl=(String) row.get("db_url");
DruidDataSource ds=new DruidDataSource();
ds.setUsername(dbUser);
ds.setPassword(dbPassWord);
ds.setUrl(dbUrl);
ds.setFilters("stat");
ds.setMaxActive(10);
ds.setInitialSize(1);
ds.setMaxWait(60000);
ds.setMinIdle(1);
ds.setTimeBetweenEvictionRunsMillis(60000);
ds.setMinEvictableIdleTimeMillis(60000);
ds.setValidationQuery("SELECT 'x'");
ds.setTestWhileIdle(true);
ds.setTestOnBorrow(false);
ds.setTestOnReturn(false);
ds.setPoolPreparedStatements(true);
ds.setMaxPoolPreparedStatementPerConnectionSize(10);
ds.setDriverClassName(dataSourceClassName);
ds.init();
JdbcTemplate jdbcTemplate=new JdbcTemplate();
jdbcTemplate.setDataSource(ds);
MicroDbHolder.getDbHolder().put(metaKey, jdbcTemplate);
}
}
示例8: createDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
public static DruidDataSource createDataSource(String dataSourceName, String driverClassName, String url, String userName, String passWord) throws Exception {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(driverClassName);
dataSource.setUrl(url);
dataSource.setUsername(userName);
dataSource.setPassword(passWord);
dataSourcesPool.put(dataSourceName, dataSource);
return dataSource;
}
示例9: ClusterDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(name = "clusterDataSource")
public DataSource ClusterDataSource(){
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(url);
datasource.setUsername(user);
datasource.setPassword(password);
datasource.setDriverClassName(driverClass);
return datasource;
}
示例10: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(initMethod = "init", destroyMethod = "close")
public DruidDataSource dataSource() throws SQLException {
if (StringUtils.isEmpty(propertyResolver.getProperty("url"))) {
System.out.println("Your database connection pool configuration is incorrect!"
+ " Please check your Spring profile, current profiles are:"
+ Arrays.toString(environment.getActiveProfiles()));
throw new ApplicationContextException(
"Database connection pool is not configured correctly");
}
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(propertyResolver.getProperty("driver-class-name"));
druidDataSource.setUrl(propertyResolver.getProperty("url"));
druidDataSource.setUsername(propertyResolver.getProperty("username"));
druidDataSource.setPassword(propertyResolver.getProperty("password"));
druidDataSource.setInitialSize(Integer.parseInt(propertyResolver.getProperty("initialSize")));
druidDataSource.setMinIdle(Integer.parseInt(propertyResolver.getProperty("minIdle")));
druidDataSource.setMaxActive(Integer.parseInt(propertyResolver.getProperty("maxActive")));
druidDataSource.setMaxWait(Integer.parseInt(propertyResolver.getProperty("maxWait")));
druidDataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(propertyResolver.getProperty("timeBetweenEvictionRunsMillis")));
druidDataSource.setMinEvictableIdleTimeMillis(Long.parseLong(propertyResolver.getProperty("minEvictableIdleTimeMillis")));
druidDataSource.setValidationQuery(propertyResolver.getProperty("validationQuery"));
druidDataSource.setTestWhileIdle(Boolean.parseBoolean(propertyResolver.getProperty("testWhileIdle")));
druidDataSource.setTestOnBorrow(Boolean.parseBoolean(propertyResolver.getProperty("testOnBorrow")));
druidDataSource.setTestOnReturn(Boolean.parseBoolean(propertyResolver.getProperty("testOnReturn")));
druidDataSource.setPoolPreparedStatements(Boolean.parseBoolean(propertyResolver.getProperty("poolPreparedStatements")));
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(Integer.parseInt(propertyResolver.getProperty("maxPoolPreparedStatementPerConnectionSize")));
druidDataSource.setFilters(propertyResolver.getProperty("filters"));
return druidDataSource;
}
示例11: clusterDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(name = "clusterDataSource")
public DataSource clusterDataSource() {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(url);
dataSource.setUsername(user);
dataSource.setPassword(password);
return dataSource;
}
示例12: masterDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(name = "masterDataSource")
@Primary
public DataSource masterDataSource() {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(url);
dataSource.setUsername(user);
dataSource.setPassword(password);
return dataSource;
}
示例13: initDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
private void initDataSource(){
dataSource=new DruidDataSource();
dataSource.setAsyncCloseConnectionEnable(true);
dataSource.setBreakAfterAcquireFailure(true);
dataSource.setDefaultAutoCommit(true);
dataSource.setDefaultReadOnly(true);
dataSource.setDriverClassName(args.getJdbcDriver());
dataSource.setEnable(true);
dataSource.setPassword(args.getPassword());
dataSource.setTestOnBorrow(true);
dataSource.setTestOnReturn(true);
dataSource.setTestWhileIdle(true);
dataSource.setUrl(args.getJdbcUrl());
dataSource.setUsername(args.getUser());
}
示例14: mysqlDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
public DataSource mysqlDataSource() throws Exception{
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setUrl(this.url);
druidDataSource.setUsername(this.username);
druidDataSource.setPassword(this.password);
druidDataSource.setDriverClassName(this.driverClassName);
druidDataSource.setInitialSize(this.initialSize);
druidDataSource.setMaxActive(this.maxActive);
druidDataSource.setMinIdle(this.minIdle);
druidDataSource.setMaxWait(this.maxWait);
druidDataSource.setTimeBetweenEvictionRunsMillis(this.timeBetweenEvictionRunsMillis);
druidDataSource.setMinEvictableIdleTimeMillis(this.minEvictableIdleTimeMillis);
druidDataSource.setValidationQuery(this.validationQuery);
druidDataSource.setTestWhileIdle(this.testWhileIdle);
druidDataSource.setTestOnBorrow(this.testOnBorrow);
druidDataSource.setTestOnReturn(this.testOnReturn);
druidDataSource.setPoolPreparedStatements(this.poolPreparedStatements);
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(this.maxPoolPreparedStatementPerConnectionSize);
druidDataSource.setFilters(this.filters);
try {
druidDataSource.setFilters("wall,stat");
druidDataSource.setUseGlobalDataSourceStat(true);
druidDataSource.init();
} catch (Exception e) {
throw new RuntimeException("load datasource error, dbProperties is :", e);
}
return druidDataSource;
}
示例15: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean
@Primary
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
// configuration
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource
.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
logger.error("druid configuration initialization filter", e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}