programming/JAVA
db에 파일 넣기
히연쓰
2021. 4. 28. 18:19
1) div -> division의 약자로, 전체적인 틀을 만들 때 주로 사용한다.
2) orm 태그에서 주요한 속성이 있는데, 바로 action과 method이다. action은 데이터를 전달할 대상을 지정하고, method는 전달 방식을 정한다.
- action: 수신 대상
- method: 전송 방식
3)
text = type
- 속성값 text는 input 요소의 기본값으로 텍스트를 입력할 수 있는 텍스트 필드가 만들어짐
- 세로 크기는 정해져 있고 가로 크기만 설정
- 크기는 글자 수를 기준으로 정해지며 기본 크기가 20
type="submit"
- 전송 버튼이 만들어진다.
type="reset"
- 초기화 버튼이 만들어진다.
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
|
<%@ 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>
<div class="member" id="insert">
<form action="insert_member_action.jsp" method="POST">
<div class="inputBox">
<label> <span class="title">이름</span> <input type="text"
name="userName">
</label>
</div>
<div class="inputBox">
<label> <span class="title">아이디</span> <input type="text"
name="userId">
</label>
</div>
<div class="inputBox">
<label> <span class="title">비밀번호</span> <input type="text"
name="userPw">
</label>
</div>
<div class="inputBox">
<label> <span class="title">이메일</span> <input type="text"
name="email">
</label>
</div>
<div class="inputBox">
<label> <span class="title">전화번호</span> <input type="text"
name="phone">
</label>
</div>
<div class="btns">
<input type="submit" value="등록"> <input type="reset"
value="취소">
</div>
</form>
</div>
</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
|
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%!
String driver = "oracle.jdbc.driver.OracleDriver";
Connection con = null;
PreparedStatement pstmt = null;
String url = "jdbc:oracle:thin:@localhost:1521:xe";
String id = "heeyeon0";
String pw = "1234";
String sql = "INSERT INTO MEMBER02 values(?,?,?,?,?)";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String userName = request.getParameter("userName");
String userId = request.getParameter("userId");
String userPw = request.getParameter("userPw");
String email = request.getParameter("email");
String phone = request.getParameter("phone");
try {
// 드라이버를 찾고
Class.forName(driver);
con = DriverManager.getConnection(url,id,pw);
System.out.println("연결 성공");
pstmt = con.prepareStatement(sql);
pstmt.setString(1, userName);
pstmt.setString(2, userId);
pstmt.setString(3, userPw);
pstmt.setString(4, email);
pstmt.setString(5, phone);
int result = pstmt.executeUpdate();
// 영향을 미쳤으면 회원가입 되었습니다.
} catch(Exception e) {
e.printStackTrace();
} finally {
try {
if(pstmt!=null) pstmt.close();
if(con!=null) con.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
%>
</body>
</html>
|
cs |
뭐 대충 이렇게 넣어진다.
사실 더 써야하지만 학원 끝날 시간이라 안녕