loginProcess.jsp > MODEL

본문 바로가기

사이트 내 전체검색

뒤로가기 MODEL

loginProcess.jsp

페이지 정보

작성자 관리자 작성일 21-07-15 19:42 조회 1,619 댓글 0

본문

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 

<%@ page import="java.sql.*"%>

<%

String id=request.getParameter("id");

String pass=request.getParameter("pass");

Class.forName("com.mysql.jdbc.Driver");

String url="jdbc:mysql://localhost:3306/test?serverTimezone=UTC";

String user="root";

String password="1111";

Connection conn=null;

PreparedStatement pstmt=null;

ResultSet rs=null;

try {

conn=DriverManager.getConnection(url, user, password);  

   pstmt=conn.prepareStatement("SELECT * FROM member2 WHERE id=?");

   pstmt.setString(1,id);

   rs=pstmt.executeQuery();

  

   if(rs.next()){

   if(pass.equals(rs.getString("password"))){

   session.setAttribute("id",id);

   out.println("<script>");

      out.println("location.href='main.jsp'");

      out.println("</script>");

   }

   }

  

   out.println("<script>");

   out.println("location.href='loginForm.jsp'");

   out.println("</script>");

}catch(Exception e){

e.printStackTrace();

  }finally{

  try{

  rs.close();

  pstmt.close();

  conn.close();

  }

  catch(Exception e){

  e.printStackTrace();

  }

  }

%>

추천0

댓글목록 0

등록된 댓글이 없습니다.


Copyright © dancePKT. All rights reserved.
PC 버전으로 보기