일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- jquery
- 추상클래스
- 전자정부
- 상속예제
- 다형성
- 업캐스팅
- 가변인자
- 자바
- angular2
- 이클립스
- Full text
- 페이징
- 다운캐스팅
- while
- 스프링
- Random
- 자바 야구게임
- Login with OAuth Authentication
- 전체텍스트
- Validations
- 로또
- 상속
- 야구게임
- full text indexing
- IBatis procedure
- 25가지 효율적인 sql작성법
- 단축키
- 전체
- 형변환
Archives
- Today
- Total
nalaolla
Method 예제 4 (Board) 본문
728x90
반응형
- package test.com;
- public class Test04BoardDAO {
- public int insert(Test04BoardVO vo) {
- System.out.println(vo.getNum());
- System.out.println(vo.getTitle());
- System.out.println(vo.getContent());
- System.out.println(vo.getWriter());
- System.out.println(vo.getRegDate());
- return 1;
- }
- public int update(Test04BoardVO vo) {
- return 2;
- }
- public int delete(Test04BoardVO vo) {
- return 3;
- }
- public Test04BoardVO search(Test04BoardVO vo){
- if (vo.getNum() == 44) {
- vo.setTitle("titles");
- }
- return vo;
- }
- public Test04BoardVO[] select() {
- Test04BoardVO[] vos = new Test04BoardVO[3];
- vos[0] = new Test04BoardVO();
- vos[0].setNum(44);
- vos[0].setTitle("board title1");
- vos[0].setContent("contents1..");
- vos[0].setWriter("daniel");
- vos[0].setRegDate();
- vos[1] = new Test04BoardVO();
- vos[1].setNum(45);
- vos[1].setTitle("board hello");
- vos[1].setContent("contents2..");
- vos[1].setWriter("Mac");
- vos[1].setRegDate();
- vos[2] = new Test04BoardVO();
- vos[2].setNum(46);
- vos[2].setTitle("ttttssssss");
- vos[2].setContent("contents3..");
- vos[2].setWriter("donahue");
- vos[2].setRegDate();
- return vos;
- }
- }
- package test.com;
- public class Test04BoardMain {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- System.out.println("============ Board =============");
- Test04BoardDAO dao = new Test04BoardDAO();
- Test04BoardVO bvo = new Test04BoardVO();
- bvo.setNum(44);
- bvo.setTitle("board title");
- bvo.setContent("contents..");
- bvo.setWriter("daniel kim");
- bvo.setRegDate();
- System.out.println("============ insert =============");
- int result = dao.insert(bvo);
- System.out.println(result);
- System.out.println("============ update =============");
- int result2 = dao.update(bvo);
- System.out.println(result2);
- System.out.println("============ delete =============");
- int result3 = dao.delete(bvo);
- System.out.println(result3);
- System.out.println("============ search =============");
- Test04BoardVO result4 = dao.search(bvo);
- System.out.println(result4.getTitle());
- System.out.println("============ select =============");
- Test04BoardVO[] result5 = dao.select();
- for (int i = 0; i < result5.length; i++) {
- System.out.print(result5[i].getNum() + " ");
- System.out.print(result5[i].getTitle() + " ");
- System.out.print(result5[i].getContent() + " ");
- System.out.print(result5[i].getWriter() + " ");
- System.out.println(result5[i].getRegDate());
- }
- }
- }
- package test.com;
- import java.util.Date;
- public class Test04BoardVO {
- private int num;
- private String title;
- private String content;
- private String writer;
- private Date regDate;
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- 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 void setNum(int num){
- this.num = num;
- }
- public int getNum() {
- return num;
- }
- public void setRegDate() {
- this.regDate = new Date();
- }
- public Date getRegDate() {
- Date today = new Date();
- return today;
- }
- }
728x90
반응형
'JAVA > 10. Method3' 카테고리의 다른 글
Method 예제 3 (Member) (0) | 2016.06.29 |
---|---|
Method 예제 2 (Score) (0) | 2016.06.29 |
Method 예제 1 (0) | 2016.06.22 |