<%@ 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 NAME = request.getParameter("NAME");
   String EMAIL = request.getParameter("EMAIL");
   String PHONENUM = request.getParameter("PHONENUM");
   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, PASSWORD, NAME from O_MEMBEr where ID = ? and PASSWORD = ?";
	   PreparedStatement pstmt = conn.prepareStatement(sql);
	   pstmt.setString(1, ID);
	   pstmt.setString(2, PASSWORD);
	   pstmt.setString(3, NAME);
	   pstmt.setString(4, EMAIL);
	   pstmt.setString(5, PHONENUM);
	   rs=pstmt.executeQuery();
	  
	  if(rs.next()){
		  pstmt=conn.prepareStatement("update O_MEMBER set PASSWORD = ? NAME = ? where ID = ?");
		  pstmt.setString(1, ID);
		  pstmt.setString(2, PASSWORD);
		  pstmt.setString(3, NAME);
		  pstmt.setString(4, EMAIL);
		  pstmt.setString(5, PHONENUM);
		  
		  pstmt.executeUpdate();
	  }
	    
			
			
		
		rs.close();
		pstmt.close();
		conn.close();  
	 	 
 	 str= "O_MEMBER 테이블에서 데이터를 성공적으로 업데이트 하였습니다.";
 	}
   catch(Exception e)
   { 
 		e.printStackTrace();
 		str = "Update Fail";
	
 	}
 %>
<html>
<head>
<title>레코드 추가</title>
</head>
<body>

  <%= str %>  <p>
  
<form method = "post" action = "list.jsp">
<input type = submit value = "회원리스트">
  
</body>
</html>