<%@ 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" %>
<%
        //session.invalidate(); // 모든세션정보 삭제
    %> 

<% request.setCharacterEncoding("utf-8");%>
<% 
   String id = (String)session.getAttribute("id");
   //String password= request.getParameter("password");
   String sql="";
   String delsql="";
   String str="";
   
   ResultSet rs=null;
   
   try{
	 
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection  conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20150001","960323");
	   sql="select id from o_member2 where id=?";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   //pstmt.setString(2, password);
	   rs=pstmt.executeQuery();
	  	    
		if(rs.next()){
			String rid=rs.getString("id");
			//String rpassword=rs.getString("password");
			 
			if(id.equals(rid)){
				delsql="delete from o_member2 where id=?";  // sql DELETE: DELETE FROM 테이블명 WHERE 삭제조건
				pstmt=conn.prepareStatement(delsql);
				pstmt.setString(1,id);
				//pstmt.setString(2,password);
				pstmt.executeUpdate();
				
			}
		}
		rs.close();
		pstmt.close();
		conn.close();
		%>
	<script>
	   alert("회원정보가 삭제되었습니다.");
	   location.href="../../list/list.jsp"; //입력창이 출력되면서 list창을 화면전환
	</script>
	 	 
 <%
  }catch(Exception e){ 
    e.printStackTrace(); 
  }
 %> 
 	<script>
	   alert("오류가 발생했습니다.");
	   location.href="../../list/list.jsp"; //입력창이 출력되면서 list창을 화면전환
	</script>
 		
<html>
<head>
<title>레코드 추가</title>
</head>
<body>
</body>
</html>