package com.liangjian.dataplatform.member.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 黄树文
 * @date 2020/4/18 10:16
 */
@Configuration
public class ClickHouseDruid {


    @Bean(autowire = Autowire.BY_NAME, value = "clickhouseDruidDataSource")
    public DruidDataSource clickhouseDruidDataSourceMaster() {
        DruidDataSource dataSource = new DruidDataSource();
        //四个基本属性
        dataSource.setDriverClassName("ru.yandex.clickhouse.ClickHouseDriver");
        dataSource.setUrl("jdbc:clickhouse://139.159.192.185:8223/default");
        dataSource.setUsername("default");
        dataSource.setPassword("79B084A8D7363488DEBFA5D151CCC9B1");
        //其他属性
        //初始大小
        dataSource.setInitialSize(1);
        //最大大小
        dataSource.setMaxActive(20);
        //最小大小
        dataSource.setMinIdle(10);
        //检查时间
        dataSource.setMaxWait(180000);
        dataSource.setMinEvictableIdleTimeMillis(60000);
        dataSource.setTimeBetweenEvictionRunsMillis(15000);

        return dataSource;
    }

}

