DriverMagerTest 와 dataSourceDriverManager Test
@Test
void driverManager() throws SQLException {
//DriverManager로 직접 connection
Connection con1 = DriverManager.getConnection(ConnectionConst.URL, ConnectionConst.USERNAME, ConnectionConst.PASSWORD);
Connection con2 = DriverManager.getConnection(ConnectionConst.URL, ConnectionConst.USERNAME, ConnectionConst.PASSWORD);
log.info("connection={}, class ={}", con1, con1.getClass());
log.info("connection={}, class ={}", con2, con2.getClass());
}
@Test
void dataSourceDriverManager() throws SQLException {
//DriverMamgerDataSource를 통한 connection
DriverManagerDataSource dataSource = new DriverManagerDataSource(ConnectionConst.URL, ConnectionConst.USERNAME, ConnectionConst.PASSWORD);
useDataSource(dataSource);
}
private void useDataSource(DriverManagerDataSource dataSource) throws SQLException {
Connection con1 = dataSource.getConnection();
Connection con2 = dataSource.getConnection();
log.info("connection={}, class ={}", con1, con1.getClass());
log.info("connection={}, class ={}", con2, con2.getClass());
}