MCPcopy Create free account
hub / github.com/castello/spring_basic / insertUser

Method insertUser

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

Source from the content-addressed store, hash-verified

82
83 // 사용자 정보를 user_info테이블에 저장하는 메서드
84 public int insertUser(User user) {
85 int rowCnt = FAIL;
86
87 Connection conn = null;
88 PreparedStatement pstmt = null;
89
90// insert into user_info (id, pwd, name, email, birth, sns, reg_date)
91// values ('asdf22', '1234', 'smith', 'aaa@aaa.com', '2022-01-01', 'facebook', now());
92 String sql = "insert into user_info values (?, ?, ?, ?,?,?, now()) ";
93
94 try {
95 conn = ds.getConnection();
96 pstmt = conn.prepareStatement(sql); // SQL Injection공격, 성능향상
97 pstmt.setString(1, user.getId());
98 pstmt.setString(2, user.getPwd());
99 pstmt.setString(3, user.getName());
100 pstmt.setString(4, user.getEmail());
101 pstmt.setDate(5, new java.sql.Date(user.getBirth().getTime()));
102 pstmt.setString(6, user.getSns());
103
104 return pstmt.executeUpdate(); // insert, delete, update;
105 } catch (SQLException e) {
106 e.printStackTrace();
107 return FAIL;
108 } finally {
109 close(pstmt, conn); // private void close(AutoCloseable... acs) {
110 }
111 }
112
113 // 매개변수로 받은 사용자 정보로 user_info테이블을 update하는 메서드
114 public int updateUser(User user) {

Callers

nothing calls this directly

Implementers 1

UserDaoImplch3/UserDaoImpl.java

Calls 7

closeMethod · 0.95
getIdMethod · 0.45
getPwdMethod · 0.45
getNameMethod · 0.45
getEmailMethod · 0.45
getBirthMethod · 0.45
getSnsMethod · 0.45

Tested by

no test coverage detected