当前位置: 首页>>代码示例>>Java>>正文


Java BasicDataSourceFactory.createDataSource方法代码示例

本文整理汇总了Java中org.apache.commons.dbcp.BasicDataSourceFactory.createDataSource方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSourceFactory.createDataSource方法的具体用法?Java BasicDataSourceFactory.createDataSource怎么用?Java BasicDataSourceFactory.createDataSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.dbcp.BasicDataSourceFactory的用法示例。


在下文中一共展示了BasicDataSourceFactory.createDataSource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: __doInit

import org.apache.commons.dbcp.BasicDataSourceFactory; //导入方法依赖的package包/类
@Override
protected void __doInit() throws Exception {
    Properties _props = new Properties();
    InputStream _in = ResourceUtils.getResourceAsStream("dbcp.properties", this.getClass());
    if (_in != null) {
        _props.load(_in);
    }
    //
    _props.put("driverClassName", __cfgMeta.getDriverClass());
    _props.put("url", __cfgMeta.getConnectionUrl());
    _props.put("username", __cfgMeta.getUsername());
    if (StringUtils.isNotBlank(__cfgMeta.getPassword()) && __cfgMeta.isPasswordEncrypted() && __cfgMeta.getPasswordClass() != null) {
        _props.put("password", __cfgMeta.getPasswordClass().newInstance().decrypt(__cfgMeta.getPassword()));
    } else {
        _props.put("password", __cfgMeta.getPassword());
    }
    __ds = (BasicDataSource) BasicDataSourceFactory.createDataSource(_props);

}
 
开发者ID:suninformation,项目名称:ymate-platform-v2,代码行数:20,代码来源:DBCPDataSourceAdapter.java

示例2: DbcpDataSource

import org.apache.commons.dbcp.BasicDataSourceFactory; //导入方法依赖的package包/类
private DbcpDataSource() throws Exception{
		InputStream in = new FileInputStream(DbcpDataSource.class.getResource("/dbcp.properties").getPath());
		Properties property = new Properties();
		property.load(in);
//		dataSource = BasicDataSourceFactory.createDataSource(property);
		dataSource = (BasicDataSource)BasicDataSourceFactory.createDataSource(property);
	}
 
开发者ID:JinPingWang,项目名称:DataSourcePool,代码行数:8,代码来源:DbcpDataSource.java

示例3: init

import org.apache.commons.dbcp.BasicDataSourceFactory; //导入方法依赖的package包/类
/**
     * 初始化连接池
     */
    public void init() {
        if (dataSource != null) {
            try {
                dataSource.close();
            } catch (Exception ignored) {
            }
            dataSource = null;
        }

        try {
            Properties p = new Properties();
            p.setProperty("driverClassName", this.driverClassName);
            p.setProperty("url", this.connectUrl);
            p.setProperty("username", this.username);
            p.setProperty("password", this.password);

            p.setProperty("maxActive", this.maxActive);
            p.setProperty("maxIdle", this.maxIdle);
            p.setProperty("maxWait", this.maxWait);
            p.setProperty("removeAbandoned", this.removeAbandoned);
            p.setProperty("removeAbandonedTimeout", this.removeAbandonedTimeout);
            p.setProperty("logAbandoned", "false");

//            p.setProperty("testOnBorrow", "true");连接验证..先关掉吧

            dataSource = (BasicDataSource) BasicDataSourceFactory.createDataSource(p);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
 
开发者ID:WhiteBlue,项目名称:eleme-hackathon,代码行数:35,代码来源:DataSourceFactory.java

示例4: createDataSource

import org.apache.commons.dbcp.BasicDataSourceFactory; //导入方法依赖的package包/类
/**
 * Returns new Pooled {@link DataSource} implementation
 *
 * @param poolProperties pool properties
 * @return new Pooled {@link DataSource} implementation
 * @throws SQLException
 */
public static DataSource createDataSource(Properties poolProperties) throws SQLException {
    assertNotNull(poolProperties);

    try {
        return BasicDataSourceFactory.createDataSource(poolProperties);
    } catch (Exception e) {
        throw new SQLException(e);
    }
}
 
开发者ID:pryzach,项目名称:midao,代码行数:17,代码来源:MjdbcPoolBinder.java

示例5: createDataSource

import org.apache.commons.dbcp.BasicDataSourceFactory; //导入方法依赖的package包/类
/**
 * Returns new Pooled {@link DataSource} implementation
 *
 * @param poolProperties pool properties
 * @return new Pooled {@link DataSource} implementation
 * @throws SQLException
 */
public static DataSource createDataSource(Properties poolProperties) throws SQLException {
    assertNotNull(poolProperties);

    try {
        return BasicDataSourceFactory.createDataSource(poolProperties);
    } catch (Exception e) {
        throw new SQLException(e.getMessage());
    }
}
 
开发者ID:pryzach,项目名称:midao,代码行数:17,代码来源:MjdbcPoolBinder.java

示例6: dataSource

import org.apache.commons.dbcp.BasicDataSourceFactory; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() throws Exception {
  return BasicDataSourceFactory.createDataSource(PoolProperties.createFromEnvironment(this.env));
}
 
开发者ID:ferstl,项目名称:spring-jdbc-oracle,代码行数:5,代码来源:CommonsDbcpDataSourceConfiguration.java


注:本文中的org.apache.commons.dbcp.BasicDataSourceFactory.createDataSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。