문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
java:jdbc:replication [2014/12/25 21:57] kwon37xi |
java:jdbc:replication [2023/02/16 13:51] (현재) kwon37xi [Java JDBC Replication Connection Pool (DataSource)] |
||
---|---|---|---|
줄 1: | 줄 1: | ||
- | ====== Java JDBC Replication Connection Pool(DataSource) ====== | + | ====== Java JDBC Replication Connection Pool (DataSource) ====== |
Master/ | Master/ | ||
- | ===== Springframework ===== | + | * [[https:// |
+ | * [[java: | ||
+ | |||
+ | ===== Springframework | ||
Spring 프레임워크를 사용할 경우에는 [[http:// | Spring 프레임워크를 사용할 경우에는 [[http:// | ||
+ | |||
+ | 이 방식은 Spring Framework의 Transaction과 함께 사용할 때만 작동한다. | ||
최종적으로 '' | 최종적으로 '' | ||
줄 18: | 줄 23: | ||
} | } | ||
+ | // 실제로 Master DB에 접속하는 커넥션 풀 | ||
DataSource masterDataSource = ...; | DataSource masterDataSource = ...; | ||
+ | |||
+ | // 실제로 Slave DB에 접속하는 커넥션 풀 | ||
DataSource slaveDataSource = ...; | DataSource slaveDataSource = ...; | ||
줄 24: | 줄 32: | ||
ReplicationRoutingDataSource rrds = new ReplicationRoutingDataSource(); | ReplicationRoutingDataSource rrds = new ReplicationRoutingDataSource(); | ||
- | Map< | + | Map< |
targetDataSources.put(" | targetDataSources.put(" | ||
targetDataSources.put(" | targetDataSources.put(" | ||
줄 30: | 줄 38: | ||
rrds.setDefaultTargetDataSource(masterDataSource); | rrds.setDefaultTargetDataSource(masterDataSource); | ||
- | // 최종 | + | // 최종적으로 Spring이 |
DataSource dataSource = new LazyConnectionDataSourceProxy(rrds); | DataSource dataSource = new LazyConnectionDataSourceProxy(rrds); | ||
</ | </ |