Development

Spring boot JdbcTemplate 적용방법

Hits: 213

build.gradle에 아래 내용 추가

implementation ‘org.springframework.boot:spring-boot-starter-jdbc’

Service class 파일에 아래와 같이 내용 추가

 

private final JdbcTemplate jdbcTemplate;

    @Autowired

    public UserService(JdbcTemplate jdbcTemplate) {

        this.jdbcTemplate = jdbcTemplate;

    }

    public void updateUser_jdbc(Long id, UserDTO userDto) {

        String sql = "UPDATE User SET userid = ?, , userpw = ? WHERE id = ?";

        jdbcTemplate.update(sql, userDto.getUserid(), userDto.getUserpw(), id);

    }

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다