오브젝트와 의존관계
-
토비의 스프링[1] 오브젝트와 의존관계Spring 2020. 12. 17. 01:20
서론 관심사 분리하여 DAO를 처리하는 방법과 싱글톤 패턴 및 애플리케이션 컨텍스트에 대해 알아보며, 제어의 역전(IoC)에 대해 알아보자. 관심사 분리 초난감 DAO 처리하기 public class UserDao { public void add(User user) throws SQLException, ClassNotFoundException { Class.forName("com.mysql.cj.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:mysql://localhost:3306/sys?serverTimezone=UTC&characterEncoding=UTF-8", "root", "1234"); PreparedStatement ps =..