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

Method updateUser

ch3/UserDao.java:114–144  ·  view source on GitHub ↗
(User user)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Implementers 1

UserDaoImplch3/UserDaoImpl.java

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