일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 다형성
- 페이징
- 자바
- 단축키
- while
- 이클립스
- 업캐스팅
- 전자정부
- full text indexing
- 가변인자
- 추상클래스
- 스프링
- Login with OAuth Authentication
- 야구게임
- 상속예제
- IBatis procedure
- 다운캐스팅
- 25가지 효율적인 sql작성법
- angular2
- 전체
- Full text
- Random
- jquery
- 로또
- 상속
- 전체텍스트
- 자바 야구게임
- 형변환
- Validations
Archives
- Today
- Total
nalaolla
Method 예제 3 (Member) 본문
728x90
반응형
- package test.com;
- public class Test03MemberDAO {
- public int insert(Test03MemberVO vo) {
- System.out.println(vo);
- System.out.println(vo.getNum());
- System.out.println(vo.getId());
- System.out.println(vo.getPw());
- System.out.println(vo.getName());
- System.out.println(vo.getTel());
- return 0;
- }
- public int update(Test03MemberVO vo){
- System.out.println(vo);
- return 0;
- }
- public int delete(Test03MemberVO vo) {
- vo = null;
- System.out.println(vo);
- System.gc();
- System.runFinalization();
- return 0;
- }
- public Test03MemberVO search(Test03MemberVO vo) {
- vo.setNum(vo.getNum());
- if (vo.getNum() == 55) {
- vo.setName("박가");
- }
- return vo;
- }
- public Test03MemberVO[] select() {
- Test03MemberVO[] vos = new Test03MemberVO[3];
- for (int i = 0; i < vos.length; i++) {
- Test03MemberVO vo = new Test03MemberVO();
- vos[i] = vo;
- vos[i].setNum(i);
- vos[i].setName("daniel_"+i);
- vos[i].setId("id_"+i);
- vos[i].setPw("pw_"+i);
- vos[i].setTel("tel_"+i);
- }
- return vos;
- }
- }
- package test.com;
- public class Test03MemberMain {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- System.out.println("========= member get/set ========");
- Test03MemberDAO dao = new Test03MemberDAO();
- Test03MemberVO mvo = new Test03MemberVO();
- mvo.setNum(1);
- mvo.setId("test");
- mvo.setPw("12345");
- mvo.setName("김덕중");
- mvo.setTel("010-1234");
- System.out.println("=========== insert ==============");
- int result = dao.insert(mvo);
- System.out.println(result);
- System.out.println("=========== update ==============");
- int result2 = dao.update(mvo);
- System.out.println(result2);
- System.out.println("=========== delete ==============");
- int result3 = dao.delete(mvo);
- System.out.println(result3);
- System.out.println("=========== search ==============");
- mvo.setNum(55);
- Test03MemberVO result4 = dao.search(mvo);
- System.out.println(result4.getNum());
- System.out.println(result4.getName());
- System.out.println(result4.getId());
- System.out.println(result4.getPw());
- System.out.println(result4.getTel());
- System.out.println("=========== select ==============");
- Test03MemberVO[] result5 = dao.select();
- for (int i = 0; i < result5.length; i++) {
- System.out.print(result5[i].getNum() + " ");
- System.out.print(result5[i].getName() + " ");
- System.out.print(result5[i].getId() + " ");
- System.out.print(result5[i].getPw() + " ");
- System.out.println(result5[i].getTel());
- }
- }
- }
- package test.com;
- public class Test03MemberVO {
- private int num;
- private String id;
- private String pw;
- private String name;
- private String tel;
- 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 String getTel() {
- return tel;
- }
- public void setTel(String tel) {
- this.tel = tel;
- }
- public void setNum(int num) {
- this.num = num;
- }
- public int getNum() {
- return num;
- }
- }
728x90
반응형
'JAVA > 10. Method3' 카테고리의 다른 글
Method 예제 4 (Board) (0) | 2016.06.29 |
---|---|
Method 예제 2 (Score) (0) | 2016.06.29 |
Method 예제 1 (0) | 2016.06.22 |