(User user)
| 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(); |
nothing calls this directly
no test coverage detected