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

Method insertUser

ch3/DBConnectionTest2Test.java:113–132  ·  view source on GitHub ↗
(User user)

Source from the content-addressed store, hash-verified

111
112 // 사용자 정보를 user_info테이블에 저장하는 메서드
113 public int insertUser(User user) throws Exception {
114 Connection conn = ds.getConnection();
115
116// insert into user_info (id, pwd, name, email, birth, sns, reg_date)
117// values ('asdf22', '1234', 'smith', 'aaa@aaa.com', '2022-01-01', 'facebook', now());
118
119 String sql = "insert into user_info values (?, ?, ?, ?,?,?, now()) ";
120
121 PreparedStatement pstmt = conn.prepareStatement(sql); // SQL Injection공격, 성능향상
122 pstmt.setString(1, user.getId());
123 pstmt.setString(2, user.getPwd());
124 pstmt.setString(3, user.getName());
125 pstmt.setString(4, user.getEmail());
126 pstmt.setDate(5, new java.sql.Date(user.getBirth().getTime()));
127 pstmt.setString(6, user.getSns());
128
129 int rowCnt = pstmt.executeUpdate(); // insert, delete, update
130
131 return rowCnt;
132 }
133
134 @Test
135 public void springJdbcConnectionTest() throws Exception {

Callers 3

insertUserTestMethod · 0.95
selectUserTestMethod · 0.95
deleteUserTestMethod · 0.95

Calls 6

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

Tested by

no test coverage detected