<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
 

<% request.setCharacterEncoding("utf-8");%>



<% 
   String ID = request.getParameter("ID");
   String PASSWORD = request.getParameter("PASSWORD");
   String sql = "";
   String delsql = "";
   
   ResultSet rs = null;
   String str = "";
   
   try
   {
	 
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection  conn = DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20172300","980612");
	   sql = "select ID from O_MEMBER where ID=?";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, ID);
	   rs = pstmt.executeQuery();
	  
	    
	    
		if(rs.next())
		{
			String rid=rs.getString("ID");
			 
			if(ID.equals(rid))
			{
				delsql = "delete from O_MEMBER where ID=?";
				pstmt = conn.prepareStatement(delsql);
				pstmt.setString(1, ID);
				pstmt.executeUpdate();
				
			}
			
		}
		rs.close();
		pstmt.close();
		conn.close();  
	 	 
 	 str = "O_MEMBER 테이블에서 제거되었습니다.";
 	}
   catch(Exception e)
   { 
 		e.printStackTrace();
 		str = "O_MEMBER 테이블에 새로운 레코드를 삭제에 실패했습니다.";
	
 	}
 %>
<html>
<head>
<title>레코드 추가</title>
</head>
<body>
  <%=str %>  <p>
  
<form method = "post" action = "list.jsp">
<input type = submit value = "회원리스트">
  
</body>
</html>