| 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); //添加符合条件记录 } } |