<%@ 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 pw = request.getParameter("pw");
    String pwc = request.getParameter("pwc");
    String name = request.getParameter("name");
    String year = request.getParameter("year");
    String month = request.getParameter("month");
    String day = request.getParameter("day");
    String post = request.getParameter("post");
    String addr1 = request.getParameter("addr1");
    String addr2 = request.getParameter("addr2");
    String email1 = request.getParameter("email1");
    String email2 = request.getParameter("email2");
    String job = request.getParameter("job");
    String birth = year + "-" + month + "-" + day;
    String addr = addr1 + " " + addr2;
    String email = email1 + "@" + email2;
    
String str = "";
  	
  	try {
  	
  	Class.forName("oracle.jdbc.driver.OracleDriver");
  	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20162505","970401");
  	PreparedStatement pstmt=conn.prepareStatement("insert into member_2(id,pw,name,birth,post,addr,email,job) values(?,?,?,?,?,?,?,?)");
  	pstmt.setString(1,id);
  	pstmt.setString(2,pw);
  	pstmt.setString(3,name);
  	pstmt.setString(4,birth);
  	pstmt.setString(5,post);
  	pstmt.setString(6,addr);
  	pstmt.setString(7,email);
  	pstmt.setString(8,job);
  	
  	pstmt.executeUpdate();
	pstmt.close();
	conn.close();
	
	str = "가입 성공 ";
  	}catch(Exception e) {
  		e.printStackTrace();
  		str="가입 실패 ";
  	}
  	%>
    <script>
  alert("<%=str%> 메인으로 돌아갑니다.!");
location.href="main.jsp";
</script>