MCPcopy Index your code
hub / github.com/castello/spring_basic / updateUser

Method updateUser

ch3/UserDaoImpl.java:117–148  ·  view source on GitHub ↗
(User user)

Source from the content-addressed store, hash-verified

115
116 // 매개변수로 받은 사용자 정보로 user_info테이블을 update하는 메서드
117 @Override
118 public int updateUser(User user) {
119 int rowCnt = FAIL; // insert, delete, update
120
121// Connection conn = null;
122// PreparedStatement pstmt = null;
123
124 String sql = "update user_info " +
125 "set pwd = ?, name=?, email=?, birth =?, sns=?, reg_date=? " +
126 "where id = ? ";
127
128 // try-with-resources - since jdk7
129 try (
130 Connection conn = ds.getConnection();
131 PreparedStatement pstmt = conn.prepareStatement(sql); // SQL Injection공격, 성능향상
132 ){
133 pstmt.setString(1, user.getPwd());
134 pstmt.setString(2, user.getName());
135 pstmt.setString(3, user.getEmail());
136 pstmt.setDate(4, new java.sql.Date(user.getBirth().getTime()));
137 pstmt.setString(5, user.getSns());
138 pstmt.setTimestamp(6, new java.sql.Timestamp(user.getReg_date().getTime()));
139 pstmt.setString(7, user.getId());
140
141 rowCnt = pstmt.executeUpdate();
142 } catch (SQLException e) {
143 e.printStackTrace();
144 return FAIL;
145 }
146
147 return rowCnt;
148 }
149
150 public void deleteAll() throws Exception {
151 Connection conn = ds.getConnection();

Callers

nothing calls this directly

Calls 7

getPwdMethod · 0.45
getNameMethod · 0.45
getEmailMethod · 0.45
getBirthMethod · 0.45
getSnsMethod · 0.45
getReg_dateMethod · 0.45
getIdMethod · 0.45

Tested by

no test coverage detected