WON.dev
chapter03 : remove_one 본문
<%@page import="org.joonzis.db.DBConnect"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8");
String id = request.getParameter("id");
String pw = request.getParameter("pw");
Connection conn = null;
PreparedStatement ps = null;
try {
conn = DBConnect.getConnection();
String sql ="delete from member where id=? and pw=?";
ps = conn.prepareStatement(sql);
ps.setString(1, id);
ps.setString(2, pw);
int result = ps.executeUpdate();
response.sendRedirect("view_all.jsp");
if(result > 0) {
System.out.println("데이터 삭제 성공!");
}else {
System.out.println("데이터 삭제 실패");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (ps != null) {
ps.close();
}
if (conn != null) {
conn.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
'JSP > DB (2)' 카테고리의 다른 글
chapter05 : update (0) | 2023.05.24 |
---|---|
chapter04 : update_one (0) | 2023.05.24 |
chapter02 : insert_one (0) | 2023.05.24 |
chapter01 : index (0) | 2023.05.24 |
DBConnect (0) | 2023.05.24 |