Java Code Examples for com.alibaba.druid.pool.DruidDataSource#configFromPropety()
The following examples show how to use
com.alibaba.druid.pool.DruidDataSource#configFromPropety() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DBHelper.java From Mars-Java with MIT License | 6 votes |
/** * 获取 DruidDataSource对象 * * @param dataSource 数据源配置 * @return DruidDataSource对象 */ private static DruidDataSource initDataSource(Properties dataSource) throws Exception { DruidDataSource druidDataSource = new DruidDataSource(); Properties properties = new Properties(); if(dataSource.getProperty("name") == null){ throw new Exception("jdbc配置缺少name属性"); } Set proSet = dataSource.keySet(); if(proSet == null){ throw new Exception("jdbc配置中缺少必要的属性"); } for(Object key : proSet){ properties.put("druid."+key, dataSource.get(key)); } druidDataSource.configFromPropety(properties); return druidDataSource; }
Example 2
Source File: DataSourceConfigFactory.java From singleton with Eclipse Public License 2.0 | 5 votes |
@Bean public JdbcTemplateAdapter dataSource2JdbcTemplate() { logger.info("-----------------begin datanode databasconfig----------------------------- "); Map<String, DataSource> druidDataSource = new HashMap<>(); for (Map<String, String> map : dsProps.getDatasoures()) { Properties props = new Properties(); for (Entry<String, String> entry : map.entrySet()) { logger.debug(entry.getKey() + "---------" + entry.getValue()); props.setProperty("druid." + entry.getKey(), entry.getValue()); } DruidDataSource subdds = new DruidDataSource(); subdds.configFromPropety(props); logger.info("init datasource" + subdds.getName()); druidDataSource.put(subdds.getName(), subdds); logger.info("-----------------end dataNode database config----------------------------- "); } if(druidDataSource.size()<1) { logger.fatal("there no data DB resource of VIP"); } JdbcTemplateAdapter jdbcTemplateAdapter = new JdbcTemplateAdapter(); for (Entry<String, DataSource> dsEntry : druidDataSource.entrySet()) { jdbcTemplateAdapter.putJdbcTemplate(dsEntry.getKey(), new JdbcTemplate(dsEntry.getValue())); } return jdbcTemplateAdapter; }
Example 3
Source File: DataBaseTransactionLogConfiguration.java From EasyTransaction with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(DataBaseForLog.class) public DataBaseForLog dataBaseForLog(DatabaseTransactionLogProperties properties){ DruidDataSource datasource = new DruidDataSource(); Map<String, String> druidPropertyMap = properties.getDruid(); Properties druidProperties = new Properties(); for(Entry<String, String> entry:druidPropertyMap.entrySet()){ druidProperties.put("druid." + entry.getKey(), entry.getValue()); } datasource.configFromPropety(druidProperties); DataBaseForLog dbForLog = new DataBaseForLog(); dbForLog.setDataSource(datasource); return dbForLog; }
Example 4
Source File: DatabaseExtensionsSuiteConfiguration.java From EasyTransaction with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(GetExtentionSuiteDatabase.class) public GetExtentionSuiteDatabase getMasterSelectorDatasource(DatabaseExtensionSuiteProperties properties) { DruidDataSource datasource = new DruidDataSource(); Map<String, String> druidPropertyMap = properties.getDbSetting(); Properties druidProperties = new Properties(); for (Entry<String, String> entry : druidPropertyMap.entrySet()) { druidProperties.put("druid." + entry.getKey(), entry.getValue()); } datasource.configFromPropety(druidProperties); return new DefaultGetExtensionSuiteDatasource(datasource, new DataSourceTransactionManager(datasource)); }