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
86
87
88
89
<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<!Doctype html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
        <style>
            * {
                margin:0;
                padding:0;
            }
            ul {
                list-style-type:none;
            }
            body {
                font-family:"맑은 고딕", "돋움";
                font-size:12px;
                color:44444;
            }
            #login_box {
                width:220px;
                height:120px;
                border:solid 1px #bbbbbb;
                border-radius:15px;
                margin:10px 0 0 10px;
                padding:10px 0 0 15px;
            }
            h2 {
                font-family:"Arial";
                margin-bottom:10px;
            }
            #login_box input {
                width:100px;
                height:18px;
            }
            #id_pass, #login_btn {
                display:inline-block;
                vertical-align:top;
            }
            #id_pass span {
                display:inline-block;
                width:20px;
            }
            #pass {
                margin-top:3px;
            }
            #login_btn button {
                margin-left:5px;
                padding:12px;
                border-radius:5px;
            }
            #btns {
                margin:12px 0 0 0;
                text-decoration:underline;
            }
            #btns li {
                margin-left:10px;
                display:inline;
            }
        </style>
    </head>
    <body>
        <form action="./loginAction2.jsp" method="post">
            <div id="login_box">
                <h2>Member Login</h2>
                <ul id="input_button">
                    <li id="id_pass">
                        <ul>
                            <li>
                                <span>ID</span>
                                <input type="text" name="id">
                            </li>
                            <li id="pass">
                                <span>PW</span>
                                <input type="password" name="pw">
                            </li>
                        </ul>
                    </li>
                    <li id="login_btn">
                        <button>로그인</button>
                    </li>
                </ul>
                <ul id="btns">
                    <li>회원가입</li>
                    <li>아이디/비밀번호 찾기</li>
                </ul>
            </div>
        </form>
    </body>
</html>
cs

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
<%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%>
<%@ page import = "java.sql.*"%>
<!Doctype html>
<%
    //request.setCharacterEncoding("EUC-KR");
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    
    String loginid = request.getParameter("id");
    String loginpw = request.getParameter("pw");
    System.out.println(loginid + "<---loginid");
    System.out.println(loginpw + "<---loginpw");
    
    Class.forName("com.mysql.jdbc.Driver");
    
    String dbaddress = "jdbc:mysql://localhost:3306/member_list?useUnicode=true&characterEncoding=euckr";
    String dbid = "root";
    String dbpw = "java0000";
    
    conn = DriverManager.getConnection(dbaddress, dbid, dbpw);
    System.out.println(conn + "<---conn");
    
    String sql = "SELECT dbid,dbpw,name,phone,email,address,memo,picture from join_member where dbid=? and dbpw=?";
    pstmt = conn.prepareStatement(sql);
    System.out.println(pstmt + "<---01 pstmt");
    
    pstmt.setString(1, loginid);
    pstmt.setString(2, loginpw);
    System.out.println(pstmt + "<---02 pstmt");
    
    rs = pstmt.executeQuery();
    System.out.println(rs + "<---rs");
    
    if(rs.next()) {
        rs.getString("dbid");
        rs.getString("name");
        rs.getString("phone");
        rs.getString("email");
        rs.getString("address");
        rs.getString("memo");
        rs.getString("picture");
        out.println("로그인 성공");
        System.out.println(rs.getString("dbid"));
        System.out.println(rs.getString("name"));
        System.out.println(rs.getString("phone"));
        System.out.println(rs.getString("email"));
        System.out.println(rs.getString("address"));
        System.out.println(rs.getString("memo"));
        System.out.println(rs.getString("picture"));
    } else {
        System.out.println("로그인 실패");
        response.sendRedirect("./loginForm2.jsp");
    }
 
%>
cs





setString(?의 번호, 입력변수) 메소드로 ?에 입력값을 대입해주지 않으면 


com.mysql.jdbc.JDBC4PreparedStatement@14ed38ee: SELECT dbid,dbpw,name,phone,email,address,memo,picture from join_member where dbid=** NOT SPECIFIED ** and dbpw=** NOT SPECIFIED **<---02 pstmt


id password를 입력해도 쿼리문에 값이 입력되지 않아서


java.sql.SQLException: No value specified for parameter 1


예외가 발생한다.


+ Recent posts