Search in sources :

Example 6 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project Mycat_plus by coderczp.

the class RehashLauncher method initDataSource.

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());
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 7 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project vip by guangdada.

the class MybatisPlusConfig method bizDataSource.

/**
 * 另一个数据源
 */
private DruidDataSource bizDataSource() {
    DruidDataSource dataSource = new DruidDataSource();
    druidProperties.config(dataSource);
    mutiDataSourceProperties.config(dataSource);
    return dataSource;
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 8 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project vip by guangdada.

the class MybatisPlusConfig method dataSourceGuns.

/**
 * guns的数据源
 */
private DruidDataSource dataSourceGuns() {
    DruidDataSource dataSource = new DruidDataSource();
    druidProperties.config(dataSource);
    return dataSource;
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 9 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project spring-cloud by Rogge666.

the class DataSourceConfig method createDataSource.

/**
 * 创建druid数据源
 * @param dataSourceName
 * @return
 */
private static DataSource createDataSource(final String dataSourceName) {
    // 使用Druid连接池连接数据库
    DruidDataSource druidDataSource = new DruidDataSource();
    druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
    druidDataSource.setUrl(String.format("jdbc:mysql://localhost:3306/%s", dataSourceName));
    druidDataSource.setUsername("root");
    druidDataSource.setPassword("123456");
    return druidDataSource;
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 10 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project Spring-Family by Sierou-Java.

the class MasterDataSourceConfig method masterDataSource.

@Bean(name = "masterDataSource")
@Primary
@ConfigurationProperties(prefix = "master.datasource")
public DataSource masterDataSource() {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setDriverClassName(driverClass);
    dataSource.setUrl(url);
    dataSource.setUsername(user);
    // System.out.println(SecurityAES.decrypt(password, "123"));
    // dataSource.setPassword(SecurityAES.decrypt(password, "123"));
    dataSource.setPassword(password);
    dataSource.setMaxActive(maxActive);
    dataSource.setInitialSize(initialSize);
    dataSource.setMinIdle(minIdle);
    // dataSource.setConnectionProperties("master.datasource.password=" + password);
    return dataSource;
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource) Primary(org.springframework.context.annotation.Primary) ConfigurationProperties(org.springframework.boot.context.properties.ConfigurationProperties) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

DruidDataSource (com.alibaba.druid.pool.DruidDataSource)474 SQLException (java.sql.SQLException)74 OracleMockDriver (com.alibaba.druid.test.util.OracleMockDriver)56 OracleExceptionSorter (com.alibaba.druid.pool.vendor.OracleExceptionSorter)50 MockDriver (com.alibaba.druid.mock.MockDriver)49 Connection (java.sql.Connection)43 Properties (java.util.Properties)41 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)35 FilterChain (com.alibaba.druid.filter.FilterChain)33 Bean (org.springframework.context.annotation.Bean)21 ResultSet (java.sql.ResultSet)20 Test (org.junit.Test)19 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)18 PreparedStatement (java.sql.PreparedStatement)14 Primary (org.springframework.context.annotation.Primary)14 MockConnection (com.alibaba.druid.mock.MockConnection)13 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)13 Method (java.lang.reflect.Method)11 Map (java.util.Map)11 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)10