Examples of DruidDataSource


Examples of com.alibaba.druid.pool.DruidDataSource

    filterList.add(filter);
    return this;
  }
 
  public boolean start() {
    ds = new DruidDataSource();
   
    ds.setUrl(url);
    ds.setUsername(username);
    ds.setPassword(password);
    if (driverClass != null)
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

    public void init(DataSourceProxy dataSourceProxy) {
        if (!(dataSourceProxy instanceof DruidDataSource)) {
            LOG.error("ConfigLoader only support DruidDataSource");
        }

        DruidDataSource dataSource = (DruidDataSource) dataSourceProxy;
        Properties connectinProperties = dataSource.getConnectProperties();

        Properties configFileProperties = loadPropertyFromConfigFile(connectinProperties);

        // 判断是否需要解密,如果需要就进行解密行动
        boolean decrypt = isDecrypt(connectinProperties, configFileProperties);
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

    filterList.add(filter);
    return this;
  }
 
  public boolean start() {
    ds = new DruidDataSource();
   
    ds.setUrl(url);
    ds.setUsername(username);
    ds.setPassword(password);
    ds.setDriverClassName(driverClass);
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

    public void init(DataSourceProxy dataSourceProxy) {
        if (!(dataSourceProxy instanceof DruidDataSource)) {
            LOG.error("ConfigLoader only support DruidDataSource");
        }

        DruidDataSource dataSource = (DruidDataSource) dataSourceProxy;
        Properties connectinProperties = dataSource.getConnectProperties();

        Properties configFileProperties = loadPropertyFromConfigFile(connectinProperties);

        // 判断是否需要解密,如果需要就进行解密行动
        boolean decrypt = isDecrypt(connectinProperties, configFileProperties);
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

        try {
            ManagementFactory.getPlatformMBeanServer().registerMBean(JdbcStatManager.getInstance(),
                                                                     new ObjectName(
                                                                                    "com.alibaba.druid:type=JdbcStatManager"));

            DruidDataSource dataSource = new DruidDataSource();

            ManagementFactory.getPlatformMBeanServer().registerMBean(dataSource,
                                                                     new ObjectName("com.alibaba.druid:type=DataSource"));

            dataSource.setUrl("jdbc:mock:");
            dataSource.setFilters("stat,trace");

            Connection conn = dataSource.getConnection();
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT 1");
            while (rs.next()) {

            }
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

            this.addDataSource("master", holder);
        }
    }

    protected DataSourceHolder createDataSourceHolder(String url, int weight) throws SQLException {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        dataSource.setMaxActive(getMaxPoolSize());
        dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); // 3 minutes
        dataSource.setTestWhileIdle(testWhileIdle);

        if (filters != null && !filters.isEmpty()) {
            dataSource.setFilters(filters);
        }
        dataSource.setProxyFilters(proxyFilters);

        DataSourceHolder holder = new DataSourceHolder(this, dataSource);
        holder.setWeight(weight);
        return holder;
    }
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

    private static final long serialVersionUID = 1026193803901107651L;

    private DruidDataSource   dataSource;

    public DruidConnectionProvider(){
        dataSource = new DruidDataSource();
    }
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

        druid();

    }

    public void druid() throws Exception {
        DruidDataSource dataSource = new DruidDataSource();

        dataSource.setInitialSize(initialSize);
        dataSource.setMaxActive(maxActive);
        dataSource.setMaxIdle(maxIdle);
        dataSource.setMinIdle(minIdle);
        dataSource.setMaxWait(maxWait);
        dataSource.setPoolPreparedStatements(true);
        dataSource.setDriverClassName(driverClass);
        dataSource.setUrl(jdbcUrl);
        dataSource.setPoolPreparedStatements(true);
        dataSource.setUsername(user);
        dataSource.setPassword(password);
        dataSource.setValidationQuery(validationQuery);
        dataSource.setTestOnBorrow(testOnBorrow);
        dataSource.setTestOnBorrow(testWhileIdle);
        dataSource.setTestOnBorrow(testOnReturn);
        dataSource.setRemoveAbandoned(removeAbandoned);
        dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout);
        dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
        dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
        dataSource.setNumTestsPerEvictionRun(numTestsPerEvictionRun);

        p0(dataSource, "druid", threadCount);

        long startMillis = System.currentTimeMillis();
        for (int i = 0; i < 1000; ++i) {
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

        password = "dragoon25";
        driverClass = "com.alibaba.druid.mock.MockDriver";
    }

    public void test_0() throws Exception {
        DruidDataSource dataSource = new DruidDataSource();

        dataSource.setInitialSize(initialSize);
        dataSource.setMaxActive(maxActive);
        dataSource.setMinIdle(minPoolSize);
        dataSource.setMaxIdle(maxPoolSize);
        dataSource.setPoolPreparedStatements(true);
        dataSource.setDriverClassName(driverClass);
        dataSource.setUrl(jdbcUrl);
        dataSource.setPoolPreparedStatements(true);
        dataSource.setUsername(user);
        dataSource.setPassword(password);
        dataSource.setValidationQuery(validationQuery);
        dataSource.setTestOnBorrow(testOnBorrow);

        for (int i = 0; i < executeCount; ++i) {
            p0(dataSource, "druid", threadCount);
        }
        System.out.println();
View Full Code Here

Examples of com.alibaba.druid.pool.DruidDataSource

public class DruidPooledStatementTest extends TestCase {

    private DruidDataSource dataSource;

    protected void setUp() throws Exception {
        dataSource = new DruidDataSource();
        dataSource.setUrl("jdbc:mock:xxx");
        dataSource.setTestOnBorrow(false);
        dataSource.getProxyFilters().add(new ErrorFilter());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.