Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Python
- 모던자바스크립트
- props
- 리액트
- You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client"
- googleColaboratory
- 인프런
- 타자 게임 만들기
- JS 개념
- ReactDOM.render is no longer supported in React 18. Use createRoot instead
- Concurrently
- react오류
- vs code 내 node
- intllij 내 Bean을 찾지 못해서 발생하는 오류
- Spring-Framework
- 모두의 파이썬
- DB Browser
- 자바스크립트
- react
- 노드에 리액트 추가하기
- node.js 설치
- spring-boot
- node.js로 로그인하기
- 계산맞추기 게임
- 웹 게임을 만들며 배우는 리액트
- Do it 자바스크립트 + 제이쿼리 입문
- Colaboratory 글자 깨짐
- 따라하며 배우는 노드 리액트 기본 강의
- intellij
- 거북이 대포 게임
Archives
- Today
- Total
프로그래밍 삽질 중
(수정 필요)JDBC&SQL를 이용해 회원 가입 폼 만들기(수정하기) 본문
※ joinProc.jsp와 updateProc.jsp의 테이블에서 읽어온 데이터 표시 안 됨
→ 수정 필요
조건
1) 필요한 파일은 총 5개(personal_info.java, joinFrm.jsp, joinProc.jsp, updateFrm.jsp, updateProc.jsp
2) SQL에서 personal_info 테이블 만들기
3) 사진에 맞는 구성 필요
[문제 답] - 순서대로 만들어야 작동함
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
|
[personal_info.java]
package javabeans;
public class personal_info {
private String id;
private String pw;
private String name;
private String age;
private String gender;
private String phonenum;
public personal_info() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPw() {
return pw;
}
public void setPw(String pw) {
this.pw = pw;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getPhonenum() {
return phonenum;
}
public void setPhonenum(String phonenum) {
this.phonenum = phonenum;
}
}
|
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
|
[joinFrm.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form name="joinForm" action="joinProc.jsp" method="post">
<left>
<h3>회원가입</h3>
<table border=1>
<tr><td>아이디</td><td><input type="text" name="id"></td></tr>
<tr><td>비밀번호</td><td><input type="password" name="pw"></td></tr>
<tr><td>이름</td><td><input type="text" name="name"></td></tr>
<tr><td>나이</td><td><input type="text" name="age"></td></tr>
<tr><td>성별(male/female)</td><td><input type="text" name="gender"></td></tr>
<tr><td>연락처</td><td><input type="text" name="phonenum"></td></tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="가입하기">
</table>
</left>
</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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
[joinProc.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.*"%>
<%request.setCharacterEncoding("utf-8"); %>
<jsp:useBean id="info" class="javabeans.personal_info"/>
<jsp:setProperty property="*" name="info"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table border="2" style="width: 750px;">
<caption>사용자가 입력한 데이터</caption>
<tr>
<td style="width: 20%;">아이디</td>
<td style="width: 40%;">${info.id }</td>
<td style="width: 20;%">비밀번호</td>
<td style="width: 40%;">${info.pw }</td>
</tr>
<tr>
<td style="width: 20%;">이름</td>
<td style="width: 40%;">${info.name }</td>
<td style="width: 20%;">나이</td>
<td style="width: 40%;">${info.age }</td>
</tr>
<tr>
<td style="width: 20%">성별</td>
<td style="width: 40%;">${info.gender }</td>
<td style="width: 20%;">연락처</td>
<td style="width: 40%;">${info.phonenum }</td>
</tr>
</table>
<%
String url = "jdbc:oracle:thin:@localhost:1521:xe";
String dbId = "scott";
String dbPwd = "tiger";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url, dbId, dbPwd);
sql = "insert into personal_info values(?,?,?,?,?,?,to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss'))";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, info.getId());
pstmt.setString(2, info.getPw());
pstmt.setString(3, info.getName());
pstmt.setString(4, info.getAge());
pstmt.setString(5, info.getGender());
pstmt.setString(6, info.getPhonenum());
pstmt.execute();
sql = "select * from personal_info where id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, info.getId());
rs = pstmt.executeQuery();
rs.next();
%>
<table border="2" style="width: 700px;">
<caption>테이블에서 읽어온 데이터</caption>
<tr>
<td style="width: 15%;">아이디</td>
<td style="width: 35%;"><%=rs.getString(1) %></td>
<td style="width: 15%;">비밀번호</td>
<td style="width: 35%;"><%=rs.getString(2) %></td>
</tr>
<tr>
<td style="width: 15%;">이름</td>
<td style="width: 35%;"><%=rs.getString(3) %></td>
<td style="width: 15%;">나이</td>
<td style="width: 35%;"><%=rs.getString(4) %></td>
</tr>
<tr>
<td style="width: 15%;">성별</td>
<td style="width: 35%;"><%=rs.getString(5) %></td>
<td style="width: 15%;">연락처</td>
<td style="width: 35%;"><%=rs.getString(6) %></td>
</tr>
<tr>
<td colspan="1">가입일</td>
<td colspan="3"><%=rs.getString(7) %></td>
</tr>
</table>
<%
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}finally{
conn.close();
}
%>
</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
57
58
59
60
|
[updateFrm.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String url = "jdbc:oracle:thin:@localhost:1521:xe";
String dbId = "scott";
String dbPwd = "tiger";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url, dbId, dbPwd);
sql = "select * from personal_info where Id='hong'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
rs.next();
%>
<form action="updatePro.jsp" method="post">
<left>
<h3>수정하기</h3>
<table border=1>
<tr><td>아이디</td><td><input type="text" name="id"></td></tr>
<tr><td>비밀번호</td><td><input type="password" name="pw"></td></tr>
<tr><td>이름</td><td><input type="text" name="name"></td></tr>
<tr><td>나이</td><td><input type="text" name="age"></td></tr>
<tr><td>성별(male/female)</td><td><input type="text" name="gender"></td></tr>
<tr><td>연락처</td><td><input type="text" name="phonenum"></td></tr>
<tr>
<td colspan="2" align=center>
<input type="submit" value="수정하기">
</tr>
</table>
</left>
</form>
<%
}catch(SQLException e){
e.printStackTrace();
}catch(ClassNotFoundException e){
e.printStackTrace();
}finally{
conn.close();
}
%>
</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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
[updateProc.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%request.setCharacterEncoding("utf-8"); %>
<jsp:useBean id="info" class="javabeans.personal_info"/>
<jsp:setProperty property="*" name="info"/>
<table border="2" style="width: 750px;">
<caption>회원 정보 수정</caption>
<tr>
<td style="width: 20%;">아이디</td>
<td style="width: 40%;">${info.id }</td>
<td style="width: 20%;">비밀번호</td>
<td style="width: 40%;">${info.pw }</td>
</tr>
<tr>
<td style="width: 20%;">이름</td>
<td style="width: 40%;">${info.name }</td>
<td style="width: 20%;">나이</td>
<td style="width: 40%;">${info.age}</td>
</tr>
<tr>
<td style="width: 20%;">성별</td>
<td style="width: 40%;">${info.gender }</td>
<td style="width: 20%;">연락처</td>
<td style="width: 40%;">${info.phonenum}</td>
</tr>
</table>
<hr>
<%
String url = "jdbc:oracle:thin:@localhost:1521:xe";
String dbId = "scott";
String dbPwd = "tiger";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url, dbId, dbPwd);
sql = "update personal_info set pw=?, name=?, age=?, gendar=?, phonenum=? where id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, info.getPw());
pstmt.setString(2, info.getName());
pstmt.setString(3, info.getAge());
pstmt.setString(4, info.getGender());
pstmt.setString(5, info.getPhonenum());
pstmt.setString(6, info.getId());
pstmt.execute();
sql = "select * from personal_info where id=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, info.getId());
rs = pstmt.executeQuery();
rs.next();
%>
<table border="2" style="width: 750px;">
<caption>테이블에서 읽어온 데이터</caption>
<tr>
<td style="width: 15%;">아이디</td>
<td style="width: 35%;"><%=rs.getString(1) %></td>
<td style="width: 15%;">비밀번호</td>
<td style="width: 35%;"><%=rs.getString(2) %></td>
</tr>
<tr>
<td style="width: 15%;">이름</td>
<td style="width: 35%;"><%=rs.getString(3) %></td>
<td style="width: 15%;">나이</td>
<td style="width: 35%;"><%=rs.getString(4) %></td>
</tr>
<tr>
<td style="width: 15%;">성별</td>
<td style="width: 35%;"><%=rs.getString(5) %></td>
<td style="width: 15%;">연락처</td>
<td style="width: 35%;"><%=rs.getString(6) %></td>
</tr>
<tr>
<td colspan="1">가입일</td>
<td colspan="3"><%=rs.getString(7) %></td>
</tr>
</table>
<%
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}finally{
conn.close();
}
%>
</body>
</html>
|
cs |
'과거 프로그래밍 자료들 > 자바(Java)' 카테고리의 다른 글
Java로 계좌 관련 문제(입금, 출금, 송금 내용 포함) (0) | 2021.05.21 |
---|---|
JSP JSTL & JDBC 데이터 로딩 (0) | 2021.04.14 |
JSP EL (Expression Language) (0) | 2021.04.13 |
JSP 쿠키(Cookie), 파일 업로드, 오류 처리 (0) | 2021.04.13 |
JSP Session & param (0) | 2021.04.12 |