JDBC(3)
-
6. SpringBoot 입문 - Spring DB 접근 기술 - Spring JdbcTemplate
H2 데이터베이스 설치 순수 JDBC Spring 통합 테스트 Spring JdbcTemplate JPA Spring Data JPA (JPA를 더 편리하게) 4. Spring JdbcTemplate Spring JdbcTemplate은 순수 Jdbc와 동일한 환경설정을 따릅니다. JdbcTemplate과 MyBatis 같은 라이브러리는 JDBC API에서의 반복적인 코드를 대부분 제거해줍니다. 하지만 SQL은 직접 작성해야 합니다. repository/JdbcTemplateMemberRepository package hello.hellospring.repository; import hello.hellospring.domain.Member; import org.springframework.jdbc.cor..
2021.05.26 -
6. SpringBoot 입문 - Spring DB 접근 기술 - 통합 테스트
H2 데이터베이스 설치 순수 JDBC Spring 통합 테스트 Spring JdbcTemplate JPA Spring Data JPA (JPA를 더 편리하게) 3. Spring 통합 테스트 Spring을 올리고 DB까지 연결해서 동작하는 테스트를 해보겠습니다. 기존에 해온 테스트는 순수Java 코드로 작성한 테스트였지만 이젠 Spring을 올린 상태에서 테스트해야 하므로.. @SpringBootTest 어노테이션을 추가해줍니다. /test/java/hello.hellospring/service/MemberServiceIntegrationTest package hello.hellospring.service; import hello.hellospring.domain.Member; import hello.he..
2021.05.26 -
6. SpringBoot 입문 - Spring DB 접근 기술 - 순수 JDBC
H2 데이터베이스 설치 순수 JDBC Spring 통합 테스트 Spring JdbcTemplate JPA Spring Data JPA (JPA를 더 편리하게) 2. 순수 JDBC 애플리케이션에서 데이터베이스와 연동하여 CRUD 하는 내용을 다뤄보겠습니다. 순수 JDBC는 오래전에 개발자들이 사용했던 방법입니다. build.gradle 파일에 jdbc, h2 데이터베이스 관련 라이브러리를 추가해줍니다. implementation 'org.springframework.boot:spring-boot-starter-jdbc' runtimeOnly 'com.h2database:h2' Java는 기본적으로 DB와 연동하려면 JDBC Driver가 꼭 있어야 합니다. 라이브러리를 추가하면 오른쪽 상단에 gradle ..
2021.05.26