正在阅读:一个简单实用的数据库操作框架一个简单实用的数据库操作框架

2004-08-16 10:34 出处:CSDN 作者:chensheng913 责任编辑:linjixiong


  public void setName(String name) {
  this.name = name;
  }
  public java.sql.Timestamp getBirthday() {
  return birthday;
  }
  public void setBirthday(java.sql.Timestamp birthday) {
  this.birthday = birthday;
  }
  public String getAddress() {
  return address;
  }
  public void setAddress(String address) {
  this.address = address;
  }
  public java.math.BigDecimal getIncome() {
  return income;
  }
  public void setIncome(java.math.BigDecimal income) {
  this.income = income;
  }
  public String toString(){
  return " 编号:" + id + " 姓名:" + name + " 生日:" + birthday
  + " 地址:" + address + " 收入:" + income;
  }
  }

 

  最后主程序的源码如下:


  package org.together.jdbcwrap.test;
  import java.util.*;
  import com.gdrj.util.database.*;

  public class GeneralDAOExample {
  public static void main(String[] args)throws Exception {
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Database db = new Database("jdbc:odbc:emmis","sa","815023");
  GeneralDAO dao = new GeneralDAO(db,"teacher");
  /**
  * 利用GeneralDAO进行查询
  */
  Collection col = dao.findDatas("*","birthday is null",null,TeacherVO.class);
  for (Iterator iter = col.iterator(); iter.hasNext(); ) {
  Object item = iter.next();
  System.out.println("item = " + item);
  }
  /**
  * 利用GeneralDAO进行添加
  */
  TeacherVO vo = new TeacherVO();
  vo.setAddress("沈阳");
  vo.setBirthday(new java.sql.Timestamp(0));
  vo.setId(new Integer(11));
  vo.setIncome(new java.math.BigDecimal(1000));
  vo.setName("陶小川");
  //    dao.insertData(vo);  //添加一条记录
  //    dao.updateData(vo,"id=10",null); //更新一条记录
  //    dao.deleteData(vo); //删除一条记录
  //    dao.deleteDatas("id>5",null); //添加符合条件记录
  }
  }







察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:
键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品