자바 오라클 회원가입 - jaba olakeul hoewongaib

자바 오라클 회원가입 - jaba olakeul hoewongaib

자바 오라클 회원가입 - jaba olakeul hoewongaib

자바 오라클 회원가입 - jaba olakeul hoewongaib





1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

 

 

import java.io.IOException;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

 

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

 

 

@WebServlet("/Check")

public class Check extends HttpServlet {

    private static final long serialVersionUID = 1L;

    

    

    public void init() throws ServletException {

        try {

        Class.forName("oracle.jdbc.driver.OracleDriver");

            System.out.println("드라이버 로드 성공");

        }catch (Exception e) {

            e.printStackTrace();

            System.out.println("드라이버 로드 실패");

        }

    }

 

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        

    }

 

 

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    

        request.setCharacterEncoding("utf-8");

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

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

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

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

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

        

        Connection con = null;

        PreparedStatement pstmt = null;

        

        String url = "jdbc:oracle:thin:@localhost:1521:XE";

        String uid = "scott";

        String pass = "tiger";

        String sql = "insert into member3 values(?,?,?,?,?)";

        

        try {

            con = DriverManager.getConnection(url, uid, pass);

            pstmt = con.prepareStatement(sql);

            

            pstmt.setString(1, newid);

            pstmt.setString(2, password);

            pstmt.setString(3, name);

            pstmt.setString(4, email);

            pstmt.setString(5, address);

            pstmt.executeUpdate();

            

            

        }catch (Exception e) {

            e.printStackTrace();

        }finally {

            try {

                if(con != null) con.close();

                if(pstmt != null) pstmt.close();

            }catch (Exception e) {

                e.printStackTrace();

            }

        }

        response.sendRedirect("zMypage.jsp");

        

        

        

        

        

        

    }

 

}

 

 

Colored by Color Scripter

cs


Check.java (회원정보 입력 소스코드)



1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

 

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

    pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>회원 정보 입력</title>

</head>

<body>

<h1>회원 정보 입력</h1>

<form action = "Check" method = "post">

<fieldset>

<legend>회원정보</legend>

<table>

<tr>

<td class = "label">아이디</td>

<td class = "field"><input type = "text" name = "newid"></td>

</tr>

<tr>

<td class = "label">비밀번호</td>

<td class = "field"><input type = "password" name = "password"></td>

</tr>

<tr>

<td class = "label">이름</td>

<td class = "field"><input type = "text" name = "name"></td>

</tr>

<tr>

<td class = "label">이메일</td>

<td class = "field"><input type = "text" name = "email"></td>

</tr>

<tr>

<td class = "label">주소</td>

<td class = "field"><input type = "text" name = "address"></td>

</tr>

</table>

<input type = "hidden" name = "action" value = "insert">

<input type = "submit" value = "저 장">

<input type = "reset" value = "취 소">

</fieldset>

</form>

</body>

</html>

Colored by Color Scripter

cs


zSignup.jsp (회원가입 양식 소스코드)






1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

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

    pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

</head>

<body>

<h3>회원가입 완료 !!</h3>

 

<a href="zSignup.jsp">회원가입을  하시려면 클릭</a><br><br>

<a href="zMember.jsp">회원정보를 확인하시려면 클릭</a>

</body>

</html>

Colored by Color Scripter

cs


zMypage.jsp




1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

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

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

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

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

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

    pageEncoding="UTF-8"%>

    <%!

        Connection con = null;

        Statement stmt = null;

        

        String url = "jdbc:oracle:thin:@localhost:1521:XE";

        String uid = "scott";

        String pwd = "tiger";

        String sql = "select * from member3";

        

    %>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

</head>

<body>

<%

    request.setCharacterEncoding("utf-8");

    Class.forName("oracle.jdbc.driver.OracleDriver");

    con = DriverManager.getConnection(url,uid,pwd);

    stmt = con.createStatement();

    ResultSet rs = stmt.executeQuery(sql);

    try {

    while(rs.next()) {

        out.println(rs.getString("newid"));

        out.println(rs.getString("password"));

        out.println(rs.getString("name"));

        out.println(rs.getString("email"));

        out.println(rs.getString("address"));

        out.println("<br><br>");

    }

    }catch (Exception e) {

        e.printStackTrace();

    }finally {

        try {

            if(con != null) con.close();

            if(stmt != null) stmt.close();

        }catch(Exception e){

            e.printStackTrace();

    }

    }

    

%>

</body>

</html>

Colored by Color Scripter

cs


zMember.jsp (회원정보 검색 소스코드)



아직 많이 부족하지만 차차 보완하고 업데이트 예정






공유하기

게시글 관리

구독하기우당탕탕 만들기

'Jsp' 카테고리의 다른 글

form 태그에 action 속성이 없는데 요청처리가 된다??  (0)2018.11.17커넥션풀 에러메시지 해결 (Oracle Property maxWait is not used in DBCP2)  (0)2018.11.01JDBC (Java Database Connectivity)  (0)2018.10.31세션(Session)  (0)2018.10.30JSP에서 자바코드를 써보자  (0)2018.10.30