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


package com.ccl.service; 
 
import java.sql.Connection; 
import java.util.List; 
 
import com.ccl.domin.BookType; 
import com.ccl.util.ConnectionFactory; 
import com.ccl.util.ConnectionUtil; 
import com.ccl.util.JdbcUtil; 
 
public class BookTypeService { 
	public void booktype_add(BookType bookType){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.insert(bookType, conn); 
		ConnectionUtil.close(conn); 
	} 
	public List<Object> booktype_list(){ 
		Connection conn=ConnectionFactory.getConnection(); 
		List<Object> lists=JdbcUtil.queryList(new BookType(), "select * from booktype_t", conn); 
		ConnectionUtil.close(conn); 
		return lists; 
	} 
	public void booktype_del( int id){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.execute("delete from booktype_t where id=?", new Object[]{id}, conn); 
		ConnectionUtil.close(conn); 
	} 
	 
	public void booktype_update(BookType bookType){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.execute("update booktype_t set name=? where id=?", new Object[]{bookType.getName(),bookType.getId()}, conn); 
		ConnectionUtil.close(conn); 
	} 
	public BookType getBooktype(int id){ 
		Connection conn=ConnectionFactory.getConnection(); 
		BookType b=(BookType) JdbcUtil.queryOne(new BookType(), "select * from booktype_t where id =?", new Object[]{id}, conn); 
		ConnectionUtil.close(conn); 
		return b; 
	} 
 
}