| 78 | } |
| 79 | |
| 80 | public User selectUser(String id) throws Exception { |
| 81 | Connection conn = ds.getConnection(); |
| 82 | |
| 83 | String sql = "select * from user_info where id= ? "; |
| 84 | |
| 85 | PreparedStatement pstmt = conn.prepareStatement(sql); // SQL Injection공격, 성능향상 |
| 86 | pstmt.setString(1,id); |
| 87 | ResultSet rs = pstmt.executeQuery(); // select |
| 88 | |
| 89 | if(rs.next()) { |
| 90 | User user = new User(); |
| 91 | user.setId(rs.getString(1)); |
| 92 | user.setPwd(rs.getString(2)); |
| 93 | user.setName(rs.getString(3)); |
| 94 | user.setEmail(rs.getString(4)); |
| 95 | user.setBirth(new Date(rs.getDate(5).getTime())); |
| 96 | user.setSns(rs.getString(6)); |
| 97 | user.setReg_date(new Date(rs.getTimestamp(7).getTime())); |
| 98 | return user; |
| 99 | } |
| 100 | return null; |
| 101 | } |
| 102 | |
| 103 | private void deleteAll() throws Exception { |
| 104 | Connection conn = ds.getConnection(); |