File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
2022-11-06
File name
Commit message
Commit date
File name
Commit message
Commit date
2022-11-06
2022-11-06
package spring.config;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* DB Connection 자원 관련 Bean 설정 Class
* DBCP: HikariCP
* JDBC: MariaDB or PostgreSQL
*
* @author 최정우
* @since 2022.09.01
*/
@Configuration
public class DataSourceContextConfig {
/**
* HikariCP(DBCP) Config(설정 세팅) 객체 Bean 설정
*
* @author 최정우
* @since 2022.09.01
*/
@Bean(name = "mainHikariConfig")
public HikariConfig getMainHikariConfig () {
HikariConfig hikariConfig = new HikariConfig();
/* MariaDB
hikariConfig.setDriverClassName("org.mariadb.jdbc.Driver");
hikariConfig.setJdbcUrl("jdbc:mariadb://localhost:3306/test");
hikariConfig.setUsername("root");
hikariConfig.setPassword("1234");
*/
/* PostgreSQL*/
hikariConfig.setDriverClassName("org.postgresql.Driver");
hikariConfig.setJdbcUrl("jdbc:postgresql://localhost:5432/test_db");
hikariConfig.setUsername("test_user");
hikariConfig.setPassword("1234");
return hikariConfig;
}
/**
* HikariCP(DBCP) 객체 Bean 설정
*
* @author 최정우
* @since 2022.09.01
*/
@Bean(name = "mainHikariDataSource")
public HikariDataSource getMainHikariDataSource () {
HikariDataSource hikariDataSource = new HikariDataSource(getMainHikariConfig());
return hikariDataSource;
}
}