<%@ 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 passwd= request.getParameter("password");
   String name=request.getParameter("name");
   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","yoon","1234");
	   sql="select id, password, name from o_member where id=? and password=?";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   pstmt.setString(2, passwd);
	   pstmt.setString(3, name);
	   rs=pstmt.executeQuery(); //결과 가져옴
	  
	  if(rs.next()){
		  pstmt=conn.prepareStatement("update o_member set password=? name=? where id=?");
		  pstmt.setString(1,id);
		  pstmt.setString(2,passwd);
		  pstmt.setString(3,name);
		  
		  pstmt.executeUpdate();
	  }
	    
		//if(rs.next()){
			//String rid=rs.getString("id");
			//String rpass=rs.getString("passwd");
			//String rname=rs.getString("name");
			 
			//if(id.equals(rid)){
				//delsql="upate o_member set id=?, password=?, name=? where id=?";
				//pstmt=conn.prepareStatement(delsql);
				//pstmt.setString(1,id);
				//pstmt.setString(2,passwd);
				//pstmt.setString(3,name);
				//pstmt.executeUpdate();
				
			
			
		
		rs.close();
		pstmt.close();
		conn.close();  
	 	 
 	 str= "0_member table에서 date update ~~~.";
 	}catch(Exception e){ 
 		e.printStackTrace();
 		str="  update fail";
	
 	}
 %>
<html>
<head>
<title>레코드 추가</title>
</head>
<body>

  <%= str %>  <p>
  
 <A href="http://localhost:8080/jsp_Test/session_project/list.jsp">click here!! </A>
  
</body>
</html>