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

Method deleteUser

ch3/UserDao.java:17–41  ·  view source on GitHub ↗
(String id)

Source from the content-addressed store, hash-verified

15 final int FAIL = 0;
16
17 public int deleteUser(String id) {
18 int rowCnt = FAIL; // insert, delete, update
19
20 Connection conn = null;
21 PreparedStatement pstmt = null;
22
23 String sql = "delete from user_info where id= ? ";
24
25 try {
26 conn = ds.getConnection();
27 pstmt = conn.prepareStatement(sql);
28 pstmt.setString(1, id);
29// int rowCnt = pstmt.executeUpdate(); // insert, delete, update
30// return rowCnt;
31 return pstmt.executeUpdate(); // insert, delete, update
32 } catch (SQLException e) {
33 e.printStackTrace();
34 return FAIL;
35 } finally {
36 // close()를 호출하다가 예외가 발생할 수 있으므로, try-catch로 감싸야함.
37// try { if(pstmt!=null) pstmt.close(); } catch (SQLException e) { e.printStackTrace();}
38// try { if(conn!=null) conn.close(); } catch (SQLException e) { e.printStackTrace();}
39 close(pstmt, conn); // private void close(AutoCloseable... acs) {
40 }
41 }
42
43 public User selectUser(String id) throws Exception {
44 User user = null;

Callers

nothing calls this directly

Implementers 1

UserDaoImplch3/UserDaoImpl.java

Calls 1

closeMethod · 0.95

Tested by

no test coverage detected