joinProcess.jsp > MODEL

본문 바로가기

사이트 내 전체검색

뒤로가기 MODEL

joinProcess.jsp

페이지 정보

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

본문

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

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

<%

request.setCharacterEncoding("UTF-8");


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

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

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

int age=Integer.parseInt(request.getParameter("age"));

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

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

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;

try {

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

  

   pstmt=conn.prepareStatement("INSERT INTO member2 VALUES (?,?,?,?,?,?)");

   pstmt.setString(1,id);

   pstmt.setString(2,pass);

   pstmt.setString(3,name);

   pstmt.setInt(4,age);

   pstmt.setString(5,gender);

   pstmt.setString(6,email);

  

   int result = pstmt.executeUpdate();

  

   if(result!=0){  

   out.println("<script>");

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

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

   }else{

   out.println("<script>");

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

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

   }

}catch(Exception e){

e.printStackTrace();

  }finally{

  try{

  pstmt.close();

  conn.close();

  }

  catch(Exception e){

  e.printStackTrace();

  }

  }

%>

추천0

댓글목록 0

등록된 댓글이 없습니다.


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