Programming241 Spring 기반의 DB 연동 - springframework 및 SpringBoot 트랜잭션 처리 5> springframework 및 SpringBoot 트랜잭션 처리 - Service 빈에서 @Transactional 어노테이션으로 트랜잭션 처리한다. - @Transactional 클래스 레벨: 클래스내의 모든 메서드가 트랜잭션 으로 처리됨. 메서드 레벨: 지정된 메서드에서만 트랜잭션 으로 처리됨. package com.exam;import java.util.List;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.CommandLineRunner;import org.sprin.. 2024. 7. 2. Spring 기반의 DB 연동 - mybatis + mysql: 연동1 - @Repository 클래스 + TodoMapper.xml 연동 4> mybatis + mysql: 연동1 - @Repository 클래스 + TodoMapper.xml 연동 가. 의존성 설정 https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter --> org.mybatis.spring.boot mybatis-spring-boot-starter 2.1.4 https://mvnrepository.com/artifact/mysql/mysql-connector-java --> mysql mysql-connector-java 8.0.33 나. DB 연동위한 4가지 정보 설정 #.. 2024. 7. 2. Spring 기반의 DB 연동 - SpringJDBC + mysql 연동 3> SpringJDBC + mysql 연동 가. 의존성 설정 org.springframework.boot spring-boot-starter-data-jdbc https://mvnrepository.com/artifact/mysql/mysql-connector-java --> mysql mysql-connector-java 8.0.33 나. DB 연동위한 4가지 정보 설정 #application properties spring.datasource.driver-class-name=cohttp://m.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/.. 2024. 7. 2. Spring 기반의 DB 연동 - SpringJDBC + h2 연동 13. Spring 기반의 DB 연동 1> JDBC vs SpringJDBC - sql 이용 - JDBC 보다 자바코드가 훨신 적음. (예외처리 불필요. 이유는 모두 RuntimeException 계열임) try { } catch (SQLException e) { // Compilechecked // Compilechecked -> ComplieUnchecked throw new RuntimeException(""); // ComplieUnchecked } - JdbcTemplate 빈을 이용해서 DB 처리. 2> SpringJDBC + h2 연동 가. 의존성 설정 org.springframework.boot spring-boot-.. 2024. 7. 2. 이전 1 ··· 4 5 6 7 8 9 10 ··· 61 다음