本文整理匯總了Java中com.alibaba.druid.pool.DruidDataSource.setPassword方法的典型用法代碼示例。如果您正苦於以下問題:Java DruidDataSource.setPassword方法的具體用法?Java DruidDataSource.setPassword怎麽用?Java DruidDataSource.setPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.alibaba.druid.pool.DruidDataSource
的用法示例。
在下文中一共展示了DruidDataSource.setPassword方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean
public DataSource dataSource() {
System.out.println("注入druid!!!");
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(propertyResolver.getProperty("url"));
datasource.setDriverClassName(propertyResolver.getProperty("driver-class-name"));
datasource.setUsername(propertyResolver.getProperty("username"));
datasource.setPassword(propertyResolver.getProperty("password"));
datasource.setInitialSize(Integer.valueOf(propertyResolver.getProperty("initial-size")));
datasource.setMinIdle(Integer.valueOf(propertyResolver.getProperty("min-idle")));
datasource.setMaxWait(Long.valueOf(propertyResolver.getProperty("max-wait")));
datasource.setMaxActive(Integer.valueOf(propertyResolver.getProperty("max-active")));
datasource.setMinEvictableIdleTimeMillis(Long.valueOf(propertyResolver.getProperty("min-evictable-idle-time-millis")));
try {
datasource.setFilters("stat,wall,stat,log4j,default");
} catch (SQLException e) {
e.printStackTrace();
}
return datasource;
}
示例2: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean
public DataSource dataSource() {
DruidDataSource druidDataSource = new DruidDataSource();
/**
* 驅動配置
*/
druidDataSource.setDriverClassName(property.getDriverClassName());
druidDataSource.setUrl(property.getUrl());
druidDataSource.setUsername(property.getUsername());
druidDataSource.setPassword(property.getPassword());
/**
* 其它鏈接池配置自行完成
*/
druidDataSource.setConnectionProperties(property.getConnectionProperties());
try {
druidDataSource.setFilters(property.getFilters());
} catch (SQLException e) {
log.error("druid configuration initialization filter", e);
}
return druidDataSource;
}
示例3: studentDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(name = "studentDataSource")
public DataSource studentDataSource() {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setUrl(studentUrl);
dataSource.setUsername(studentUser);
dataSource.setPassword(studentPassword);
dataSource.setDriverClassName(studentDriverClass);
//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);
return dataSource;
}
示例4: init
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
/**
* 初始化操作
*
* @param modelName 模塊名稱
* @param txConfig 配置信息
*/
@Override
public void init(String modelName, TccConfig txConfig) {
dataSource = new DruidDataSource();
final TccDbConfig tccDbConfig = txConfig.getTccDbConfig();
dataSource.setUrl(tccDbConfig.getUrl());
dataSource.setDriverClassName(tccDbConfig.getDriverClassName());
dataSource.setUsername(tccDbConfig.getUsername());
dataSource.setPassword(tccDbConfig.getPassword());
dataSource.setInitialSize(tccDbConfig.getInitialSize());
dataSource.setMaxActive(tccDbConfig.getMaxActive());
dataSource.setMinIdle(tccDbConfig.getMinIdle());
dataSource.setMaxWait(tccDbConfig.getMaxWait());
dataSource.setValidationQuery(tccDbConfig.getValidationQuery());
dataSource.setTestOnBorrow(tccDbConfig.getTestOnBorrow());
dataSource.setTestOnReturn(tccDbConfig.getTestOnReturn());
dataSource.setTestWhileIdle(tccDbConfig.getTestWhileIdle());
dataSource.setPoolPreparedStatements(tccDbConfig.getPoolPreparedStatements());
dataSource.setMaxPoolPreparedStatementPerConnectionSize(tccDbConfig.getMaxPoolPreparedStatementPerConnectionSize());
this.tableName = RepositoryPathUtils.buildDbTableName(modelName);
executeUpdate(SqlHelper.buildCreateTableSql(tccDbConfig.getDriverClassName(), tableName));
}
示例5: 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;
}
示例6: 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;
}
示例7: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(initMethod = "init", destroyMethod = "close")
public DataSource dataSource() throws SQLException {
if (StringUtils.isEmpty(datasourcePropertyResolver.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.setUrl(datasourcePropertyResolver.getProperty("url"));
druidDataSource.setUsername(datasourcePropertyResolver
.getProperty("username"));
druidDataSource.setPassword(datasourcePropertyResolver
.getProperty("password"));
druidDataSource.setInitialSize(1);
druidDataSource.setMinIdle(1);
druidDataSource.setMaxActive(20);
druidDataSource.setMaxWait(60000);
druidDataSource.setTimeBetweenEvictionRunsMillis(60000);
druidDataSource.setMinEvictableIdleTimeMillis(300000);
druidDataSource.setValidationQuery("SELECT 'x'");
druidDataSource.setTestWhileIdle(true);
druidDataSource.setTestOnBorrow(false);
druidDataSource.setTestOnReturn(false);
return druidDataSource;
}
示例8: 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;
}
示例9: businessDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(initMethod = "init", destroyMethod = "close")
@Primary
public DruidDataSource businessDataSource() throws SQLException, DESException {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(dbConfigProperties.getDriveClass());
druidDataSource.setUrl(dbConfigProperties.getBusinessUrl());
druidDataSource.setUsername(dbConfigProperties.getBusinessUsername());
druidDataSource.setPassword(dbConfigProperties.getBusinessPassword());
druidDataSource.setInitialSize(dbConfigProperties.getInitialSize());
druidDataSource.setMinIdle(dbConfigProperties.getMinIdle());
druidDataSource.setMaxActive(dbConfigProperties.getMaxActive());
druidDataSource.setMaxWait(dbConfigProperties.getMaxWait());
druidDataSource.setTimeBetweenEvictionRunsMillis(dbConfigProperties.getTimeBetweenEvictionRunsMillis());
druidDataSource.setMinEvictableIdleTimeMillis(dbConfigProperties.getMinEvictableIdleTimeMillis());
//此項如果為空,下麵幾個test都不會生效
druidDataSource.setValidationQuery(dbConfigProperties.getValidationQuery());
druidDataSource.setTestWhileIdle(dbConfigProperties.getTestWhileIdle());
druidDataSource.setTestOnBorrow(dbConfigProperties.getTestOnBorrow());
druidDataSource.setTestOnReturn(dbConfigProperties.getTestOnReturn());
//5.5以後的mysql開啟,以後的關閉
druidDataSource.setPoolPreparedStatements(dbConfigProperties.getPoolPreparedStatements());
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(dbConfigProperties.getMaxPoolPreparedStatementPerConnectionSize());
druidDataSource.setFilters(dbConfigProperties.getFilters());
return druidDataSource;
}
示例10: 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;
}
示例11: dataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean //聲明其為Bean實例
public DataSource dataSource(){
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(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);
datasource.setUseGlobalDataSourceStat(useGlobalDataSourceStat);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
System.err.println("druid configuration initialization filter: "+ e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}
示例12: start
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
public boolean start() {
ds = new DruidDataSource();
ds.setUrl(url);
ds.setUsername(username);
ds.setPassword(password);
ds.setDriverClassName(driverClass);
ds.setInitialSize(initialSize);
ds.setMinIdle(minIdle);
ds.setMaxActive(maxActive);
ds.setMaxWait(maxWait);
ds.setTimeBetweenConnectErrorMillis(timeBetweenConnectErrorMillis);
ds.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
ds.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
ds.setValidationQuery(validationQuery);
ds.setTestWhileIdle(testWhileIdle);
ds.setTestOnBorrow(testOnBorrow);
ds.setTestOnReturn(testOnReturn);
ds.setRemoveAbandoned(removeAbandoned);
ds.setRemoveAbandonedTimeoutMillis(removeAbandonedTimeoutMillis);
ds.setLogAbandoned(logAbandoned);
//隻要maxPoolPreparedStatementPerConnectionSize>0,poolPreparedStatements就會被自動設定為true,參照druid的源碼
ds.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
if (StrKit.notBlank(filters))
try {ds.setFilters(filters);} catch (SQLException e) {throw new RuntimeException(e);}
addFilterList(ds);
return true;
}
示例13: buildDruidDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
/**
* 創建數據源,有前綴
*
* @param dataSourceMap
* @param prefix
* @return
* @throws SQLException
*/
private DruidDataSource buildDruidDataSource(Map<String, Object> dataSourceMap, String prefix) throws SQLException {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setName(MapUtils.getString(dataSourceMap, prefix + "name"));
dataSource.setDriverClassName(MapUtils.getString(dataSourceMap, prefix + "driverClass"));
dataSource.setUrl(MapUtils.getString(dataSourceMap, prefix + "url"));
dataSource.setUsername(MapUtils.getString(dataSourceMap, prefix + "username"));
dataSource.setPassword(MapUtils.getString(dataSourceMap, prefix + "password"));
// 配置過濾器
WallFilter wallFilter = new WallFilter();
StatFilter statFilter = new StatFilter();
statFilter.setSlowSqlMillis(5000);
statFilter.setLogSlowSql(true);
statFilter.setMergeSql(true);
Slf4jLogFilter slf4jLogFilter = new Slf4jLogFilter();
slf4jLogFilter.setDataSourceLogEnabled(false);
slf4jLogFilter.setConnectionLogEnabled(false);
slf4jLogFilter.setConnectionLogErrorEnabled(true);
slf4jLogFilter.setResultSetLogEnabled(false);
slf4jLogFilter.setResultSetLogErrorEnabled(true);
slf4jLogFilter.setStatementLogEnabled(false);
slf4jLogFilter.setStatementExecutableSqlLogEnable(true);
slf4jLogFilter.setStatementSqlFormatOption(new SQLUtils.FormatOption(false, false));
List filterList = new ArrayList();
filterList.add(wallFilter);
filterList.add(statFilter);
filterList.add(slf4jLogFilter);
dataSource.setProxyFilters(filterList);
return dataSource;
}
示例14: 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;
}
示例15: 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;
}