반응형
Model 1 (기초)간략 로그인 기능 만들기..
기본적으로 오라클 DB와 연동해서 진행을 하였으며,
DB 테이블 구성은 아이디, 비밀번호, 이름, 번호 입니다.
JDK 1.8 버전
Ojdbc7 버전
UserDBBean.class (DTO)
- DB 와 데이터 교환을 위해 객체 생성
- getter, setter 메서드로만 이루어짐
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
|
package myproject.user.bean;
public class UserDBBean {
private String id;
private String pw;
private String name;
private int phone;
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 int getPhone() {
return phone;
}
public void setPhone(int phone) {
this.phone = phone;
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
|
UserDBDAO.class (DAO)
- DB연결 로직 및 회원가입을 위한 Insert 메서드
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
|
package myproject.user.bean;
public class UserDBDAO {
public void UserInsert(UserDBBean User) {
int count = 0;
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection con = null;
try {
String url = "jdbc:oracle:thin:@localhost:1521:XE";
String user = "dbuser";
String pwd = "dbpwd";
Class.forName(DriverName);
con = DriverManager.getConnection(url, user, pwd);
System.out.println("db연결 성공");
String sql = "insert into tbl_user values(?,?,?,?)";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, User.getId());
pstmt.setString(2, User.getPw());
pstmt.setString(3, User.getName());
pstmt.setInt(4, User.getPhone());
count = pstmt.executeUpdate();
if(count > 0 ) {
System.out.println("인서트 성공");
}else {
System.out.println("인서트 실패");
}
}catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
|
반응형
'JAVA' 카테고리의 다른 글
Model1 간략한 로그인 기능 만들기 - 로그인 (0) | 2019.05.28 |
---|---|
Model1 간략한 로그인 기능 만들기 - 회원가입(Join) (0) | 2019.05.23 |
Model 1 간략한 게시판 만들기(delete.jsp) (0) | 2019.05.21 |
Model 1 간략한 게시판 만들기(content.jsp) (0) | 2019.05.21 |
Model 1 간략한 게시판 만들기(list.jsp) (0) | 2019.05.21 |