如何建立一個DAO

          Posted on 2006-11-26 20:23 黑夜ちつ獨(dú)行者 閱讀(235) 評論(0)  編輯  收藏
          ???首先我們先建立一個接口StudnetDao
          ? public interfaces StudentDao{
          ????????????public void insert(Student student);
          }

          再用一個類來實(shí)現(xiàn)該接口

          public class?StudentDaoimp implements StudentDao{
          ?????????public void insert(Student student){
          ??????}
          }

          用一個工廠來產(chǎn)生對象

          public class DaoFactory{
          ??????public static StudentDao getStudentDao(){
          ????????????return new StudentDaoimp();?????????
          ??????}
          }

          public class Student{
          ??????private int studentID;

          ???public int getStudentID() {
          ?????return studentID;
          ?}
          ?public void setStudentID(int age) {
          ?????this.studentID= studentID;
          ?}


          }

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 闵行区| 迭部县| 乌什县| 永年县| 栾川县| 丽江市| 甘泉县| 灵台县| 盐津县| 神木县| 茂名市| 桂东县| 姜堰市| 日土县| 醴陵市| 萝北县| 邯郸市| 荆门市| 汉沽区| 新田县| 普洱| 余姚市| 阳春市| 临安市| 石狮市| 毕节市| 兴和县| 屏南县| 开封县| 昭苏县| 岳普湖县| 泰宁县| 宝丰县| 成武县| 普格县| 枝江市| 桐乡市| 克拉玛依市| 上思县| 吉林省| 大荔县|