관리 메뉴

nkdk의 세상

28장 회원 가입 및 로그인 아웃 전부 java 파일 본문

My Programing/JSP and Servlet

28장 회원 가입 및 로그인 아웃 전부 java 파일

nkdk 2008. 3. 9. 01:09
좀 파일이 많네요.
DBConnectionMgr.java
MemberBean.java
MemberMgr.java
ZipcodeBean.java 자바 부터 올립니다.

MemberBean.java


package pac;

public class MemberBean {
private String mem_id;
private String mem_passwd;
private String mem_repasswd;
private String mem_name;
private String mem_num1;
private String mem_num2;
private String mem_email;
private String mem_phone;
private String mem_zipcode;
private String mem_address;
private String mem_job;

public String getMem_address() {
return mem_address;
}
public void setMem_address(String mem_address) {
this.mem_address = mem_address;
}
public String getMem_email() {
return mem_email;
}
public void setMem_email(String mem_email) {
this.mem_email = mem_email;
}
public String getMem_id() {
return mem_id;
}
public void setMem_id(String mem_id) {
this.mem_id = mem_id;
}
public String getMem_job() {
return mem_job;
}
public void setMem_job(String mem_job) {
this.mem_job = mem_job;
}
public String getMem_name() {
return mem_name;
}
public void setMem_name(String mem_name) {
this.mem_name = mem_name;
}
public String getMem_num1() {
return mem_num1;
}
public void setMem_num1(String mem_num1) {
this.mem_num1 = mem_num1;
}
public String getMem_num2() {
return mem_num2;
}
public void setMem_num2(String mem_num2) {
this.mem_num2 = mem_num2;
}
public String getMem_passwd() {
return mem_passwd;
}
public void setMem_passwd(String mem_passwd) {
this.mem_passwd = mem_passwd;
}
public String getMem_phone() {
return mem_phone;
}
public void setMem_phone(String mem_phone) {
this.mem_phone = mem_phone;
}
public String getMem_repasswd() {
return mem_repasswd;
}
public void setMem_repasswd(String mem_repasswd) {
this.mem_repasswd = mem_repasswd;
}
public String getMem_zipcode() {
return mem_zipcode;
}
public void setMem_zipcode(String mem_zipcode) {
this.mem_zipcode = mem_zipcode;
}
}


MemberMgr.java

package pac;
import java.sql.*;
import java.util.*;

public class MemberMgr {
private DBConnectionMgr pool;
Connection conn;
PreparedStatement pstmt;
ResultSet rs;
public MemberMgr() {
try {
pool=DBConnectionMgr.getInstance();
} catch (Exception e) {
System.out.println("DB 연결 오류:" + e);
}
}
public Vector zipcodeRead(String area3){
Vector<ZipcodeBean> vc = new Vector<ZipcodeBean>();
try {
conn = pool.getConnection();
String sql = "select * from zipcode where area3 like '" + area3 + "%'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()){
ZipcodeBean temp = new ZipcodeBean();
temp.setCode(rs.getString("code"));
temp.setArea1(rs.getString("area1"));
temp.setArea2(rs.getString("area2"));
temp.setArea3(rs.getString("area3"));
temp.setArea4(rs.getString("area4"));
vc.add(temp);
}
} catch (Exception e) {
System.out.println("zipcodeRead 에러 : " + e);
}finally{
pool.freeConnection(conn, pstmt, rs);
}
return vc;
}

public boolean checkId(String id) {
boolean chk = false;
try {
conn = pool.getConnection();
String sql = "select * from member where id='"+id+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next())
chk = true;
} catch (Exception e) {
System.out.println("zipcodeRead 에러 : " + e);
}finally{
pool.freeConnection(conn, pstmt, rs);
}
return chk;
}

public boolean saveData(MemberBean data) {
boolean cnt = false;
try {
String sql = "insert into member values(?,?,?,?,?,?,?,?,?,?)";
conn = pool.getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, data.getMem_id());
pstmt.setString(2, data.getMem_passwd());
pstmt.setString(3, data.getMem_name());
pstmt.setString(4, data.getMem_num1());
pstmt.setString(5, data.getMem_num2());
pstmt.setString(6, data.getMem_email());
pstmt.setString(7, data.getMem_phone());
pstmt.setString(8, data.getMem_zipcode());
pstmt.setString(9, data.getMem_address());
pstmt.setString(10, data.getMem_job());
int re = pstmt.executeUpdate();
if(re > 0) cnt = true;
} catch (Exception e) {
System.out.println("저장실패:"+e);
}finally{
try {
pool.freeConnection(conn,pstmt);
} catch (Exception e) {}
}
return cnt;
}

public boolean loginCheck(String id, String pw) {
boolean chk = false;
try {
conn = pool.getConnection();
String sql = "select * from member where id='"+id+"' and passwd='"+pw+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next())
chk = true;
} catch (Exception e) {
System.out.println("zipcodeRead 에러 : " + e);
}finally{
pool.freeConnection(conn, pstmt, rs);
}
return chk;
}

}


ZipcodeBean.java

package pac;

public class ZipcodeBean {
private String code;
private String area1;
private String area2;
private String area3;
private String area4;
public String getArea1() {
return area1;
}
public void setArea1(String area1) {
this.area1 = area1;
}
public String getArea2() {
return area2;
}
public void setArea2(String area2) {
this.area2 = area2;
}
public String getArea3() {
return area3;
}
public void setArea3(String area3) {
this.area3 = area3;
}
public String getArea4() {
return area4;
}
public void setArea4(String area4) {
this.area4 = area4;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}


입니다.