위로 아래

데이터베이스 테이블 생성

MySQL 이용, board 테이블 생성

CREATE TABLE board(
bno INT NOT NULL,
bref INT,
bstep INT,
blevel INT,
readcount INT,
subject VARCHAR(100) NOT NULL,
content TEXT NOT NULL,
writer VARCHAR(20) NOT NULL,
regdate VARCHAR(20) NOT NULL,
ip VARCHAR(20) NOT NULL,
passwd VARCHAR(20) NOT NULL);

bno : primary key 값

bref : 글 순서

bstep : 답글 기능을 위해 추가

blevel : 답글 기능을 위해 추가

readcount : 조회수

subject : 제목

content : 글 내용

writer : 작성자

regdate : 글 쓴 시각

ip : 작성자 ip

passwd : 비밀번호

 

 

 

 

DTO 생성

DTO는 데이터 전달을 위해 사용.

게터와 세터만을 지닌다. 

데이터베이스에 있는 항목들과, 추가로 rn(rownum) 변수를 private 변수로 지정

private int rn;
private int bno;
private int bref;
private int bstep;
private int blevel;
private int readcount;
private String subject;
private String content;
private String writer;
private String regdate;
private String ip;
private String passwd;

 

게터와 세터 생성

public int getRn() {
    return rn;
}
public void setRn(int rn) {
    this.rn = rn;
}

public int getBno() {
    return bno;
}
public void setBno(int bno) {
    this.bno = bno;
}

public int getBref() {
    return bref;
}
public void setBref(int bref) {
    this.bref = bref;
}

public int getBstep() {
    return bstep;
}
public void setBstep(int bstep) {
    this.bstep = bstep;
}

public int getBlevel() {
    return blevel;
}
public void setBlevel(int blevel) {
    this.blevel = blevel;
}

public int getReadcount() {
    return readcount;
}
public void setReadcount(int readcount) {
    this.readcount = readcount;
}

public String getSubject() {
    return subject;
}
public void setSubject(String subject) {
    this.subject = subject;
}

public String getContent() {
    return content;
}
public void setContent(String content) {
    this.content = content;
}

public String getWriter() {
    return writer;
}
public void setWriter(String writer) {
    this.writer = writer;
}

public String getRegdate() {
    return regdate;
}
public void setRegdate(String regdate) {
    this.regdate = regdate;
}

public String getIp() {
    return ip;
}
public void setIp(String ip) {
    this.ip = ip;
}

public String getPasswd() {
    return passwd;
}
public void setPasswd(String passwd) {
    this.passwd = passwd;
}

 

 

 

 


전체코드

package bean;

public class BoardDTO {
	private int rn;
	private int bno;
	private int bref;
	private int bstep;
	private int blevel;
	private int readcount;
	private String subject;
	private String content;
	private String writer;
	private String regdate;
	private String ip;
	private String passwd;
	
	public int getRn() {
		return rn;
	}
	public void setRn(int rn) {
		this.rn = rn;
	}
	
	public int getBno() {
		return bno;
	}
	public void setBno(int bno) {
		this.bno = bno;
	}
	
	public int getBref() {
		return bref;
	}
	public void setBref(int bref) {
		this.bref = bref;
	}
	
	public int getBstep() {
		return bstep;
	}
	public void setBstep(int bstep) {
		this.bstep = bstep;
	}
	
	public int getBlevel() {
		return blevel;
	}
	public void setBlevel(int blevel) {
		this.blevel = blevel;
	}
	
	public int getReadcount() {
		return readcount;
	}
	public void setReadcount(int readcount) {
		this.readcount = readcount;
	}
	
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	
	public String getWriter() {
		return writer;
	}
	public void setWriter(String writer) {
		this.writer = writer;
	}
	
	public String getRegdate() {
		return regdate;
	}
	public void setRegdate(String regdate) {
		this.regdate = regdate;
	}
	
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	
	public String getPasswd() {
		return passwd;
	}
	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	
}