<%@ 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");
ResultSet rs=null;

String sql=null;
try{
	   Class.forName("oracle.jdbc.driver.OracleDriver");
	   Connection  conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162486","970409");
	   sql="select * from MEMBER_2A where id=? ";
	   PreparedStatement pstmt=conn.prepareStatement(sql);
	   pstmt.setString(1, id);
	   
	   rs=pstmt.executeQuery(); //결과 가져옴                          
	  
	  if(rs.next()){
	  String dbPass=rs.getString("id");
	  if(password.equals(dbPass)){
	  	  pstmt=conn.prepareStatement("update MEMBER_2A set name=? where id=? and password=?");
		                                    //UPDATE 테이블명 SET 컬럼명=새로운값 WHERE 업데이트조건 
		  pstmt.setString(1,name);
		  pstmt.setString(2,id);
		  pstmt.setString(3,password);
		  
		  pstmt.executeUpdate();
		  
		  rs.close();
			pstmt.close();
			conn.close();  
		  
		  response.sendRedirect("success.jsp");
		  

	 }}}catch(Exception e){
	
	e.printStackTrace();

}
%>
<html>
<head>
<title>레코드 추가</title>
</head>
<body bgcolor="F5F5DC" align="center">
<script>
alert("계정을 확인해 주세요.");
location.href="main.jsp";
</script>
</body>
</html>
