본문 바로가기
boostcource/boostcourse_web programming

Insert, Update

by sgyeong 2024. 7. 2.

Insert문을 실행하기 위해서는 SimpleJdbcInsert 객체가 필요하다.

SimpleJdbcInsert 객체를 선언해준다.



insertAction에 SimpleJdbcInsert를 생성한다. dataSource를 넣어서 생성해준다. Role 객체를 받아들여서 해당 role 객체에 있는 값을 맵으로 바꿔주는데 이때 선언한 roleId를 컬럼명 role_id로 알아서 맵 객체를 생성해줄 것이다.

 

이렇게 생성한  맵 객체를 SimpleJdbcInsert 가 갖고 있는 execute의 파라미터로 전달할 경우 값이 알아서 저장되게 된다. 

 

RoleDao

 

 

테스트를 하기 위해 main 패키지에 JDBCTest 클래스를 만들어준다.

 

 

 

결과

 

 

 

update문

 

 

roleDao에 update문을 넣어준다.

 

 

201번의 description을 PROGRAMMER로 수정해준다.

 

결과

 

 

 

참고  :  https://www.boostcourse.org/web316/lecture/254340?isDesc=false

 

웹 프로그래밍(풀스택)

부스트코스 무료 강의

www.boostcourse.org

 

https://www.tutorialspoint.com/design_pattern/data_access_object_pattern.htm

 

Data Access Object Pattern

Data Access Object Pattern - Data Access Object Pattern or DAO pattern is used to separate low level data accessing API or operations from high level business services. Following are the participants in Data Access Object Pattern.

www.tutorialspoint.com

https://ejbvn.wordpress.com/category/week-2-entity-beans-and-message-driven-beans/day-09-using-jdbc-to-connect-to-a-database/

 

Day 09. Using JDBC to Connect to a Database – EJB In 21 Days ?

Today, you’ll learn how to use Java Database Connectivity (JDBC) to connect components of an enterprise application to any data source. JDBC is the standard and unified API to access any data in a tabular form, whether it is a relational database, spread

ejbvn.wordpress.com

 

 

'boostcource > boostcourse_web programming' 카테고리의 다른 글

Spring MVC  (0) 2024.07.07
Select, Delete  (0) 2024.07.06
Select  (0) 2024.07.01
Spring JDBC 실습  (0) 2024.06.30
Spring JDBC를 이용한 DAO 개발  (0) 2024.06.30