<%@ 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.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.DriverManager" %>

<% request.setCharacterEncoding("utf-8"); %>

<%
String valid_id = request.getParameter("valid_id");
ResultSet rs=null;


try{
	 
	Class.forName("oracle.jdbc.driver.OracleDriver");
	Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@168.126.146.45:1521:orcl","20161505","961120");
	PreparedStatement pstmt = conn.prepareStatement("select * from log_member");
		rs=pstmt.executeQuery();
		int i=0;
		while(rs.next()){
			String dbId=rs.getString("id");
			
			if(valid_id.equals(dbId)){ 
				i=1;
			} else {
				i=0;
			}
			if(i==1){
				break;
			}
		}
		
		if(i==1){ 
			out.print(i);
		%>
			<script>
				alert("이미 사용중인 아이디입니다.");
				location.href="IdChk.jsp";
			</script>
		<%} else { 
			out.print(i);

			session.setAttribute("valid_id",valid_id);
		%>

			<script>
				
				alert("사용 가능한 아이디입니다.");
				location.href="JoinMemberForm.jsp";
			</script>
		<%}
		
}catch(Exception e){ 
		e.printStackTrace();
		out.print("오류");
}
%>

