www.pudn.com > liberSystem.rar > ReaderService.java, change:2012-06-06,size:1569b


package com.ccl.service; 
 
import java.sql.Connection; 
import java.util.List; 
 
import com.ccl.domin.Reader; 
import com.ccl.util.ConnectionFactory; 
import com.ccl.util.ConnectionUtil; 
import com.ccl.util.JdbcUtil; 
 
public class ReaderService extends BaseService{ 
	 
	public List<Object> reader_list(){ 
		Connection conn=ConnectionFactory.getConnection(); 
		List<Object> lists=JdbcUtil.queryList(new Reader(), "select * from reader_t", conn); 
		ConnectionUtil.close(conn); 
		return lists; 
	} 
	 
	public void reader_add(Reader r){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.insert(r, conn); 
		ConnectionUtil.close(conn); 
	} 
	 
	public void reader_del(int id){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.execute("delete from reader_t where id=?", new Object[]{id}, conn); 
		ConnectionUtil.close(conn); 
	} 
	public void reader_update(Reader r){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.update(r, "id="+r.getId(), conn); 
		ConnectionUtil.close(conn); 
	} 
	public Reader getReaderByID(int id){ 
		Connection conn=ConnectionFactory.getConnection(); 
		Reader r=(Reader)JdbcUtil.queryOne(new Reader(), "select * from reader_t where id=?",new Object[]{id}, conn); 
		ConnectionUtil.close(conn); 
		return r; 
	} 
	public Reader getReaderByCondetion(String condtion){ 
		Connection conn=ConnectionFactory.getConnection(); 
		Reader r=(Reader)JdbcUtil.queryOne(new Reader(), "select * from reader_t "+condtion,new Object[]{}, conn); 
		ConnectionUtil.close(conn); 
		return r; 
	} 
 
}