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


package com.ccl.service; 
 
import java.sql.Connection; 
import java.util.List; 
 
import com.ccl.domin.Book; 
import com.ccl.util.ConnectionFactory; 
import com.ccl.util.ConnectionUtil; 
import com.ccl.util.JdbcUtil; 
 
public class BookService extends BaseService { 
	 
	public List<Object> book_list(){ 
		Connection conn=ConnectionFactory.getConnection(); 
		List<Object> lists=JdbcUtil.queryList(new Book(), "select * from book_t", conn); 
		ConnectionUtil.close(conn); 
		return lists; 
	} 
	 
	public void book_add(Book b){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.insert(b, conn); 
		ConnectionUtil.close(conn); 
	} 
	 
	public Book getBookByID(int id){ 
		Connection conn=ConnectionFactory.getConnection(); 
		Book b=(Book)JdbcUtil.queryOne(new Book(), "select * from book_t where id=?", new Object[]{id}, conn); 
		ConnectionUtil.close(conn); 
		return b; 
	} 
	 
	public Book getBookByCondtion(String condtion){ 
		Connection conn=ConnectionFactory.getConnection(); 
		Book b=(Book)JdbcUtil.queryOne(new Book(), "select * from book_t "+condtion, new Object[]{}, conn); 
		ConnectionUtil.close(conn); 
		return b; 
	} 
	 
	public void book_del(int id){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.execute("delete from book_t where id=?", new Object[]{id}, conn); 
		ConnectionUtil.close(conn); 
	} 
	public void book_update(Book b){ 
		Connection conn=ConnectionFactory.getConnection(); 
		JdbcUtil.execute("update book_t set bookName=?,author=?,publisher=?,price=?,type=? where id=?", new Object[]{b.getBookName(),b.getAuthor(),b.getPublisher(),b.getPrice(),b.getType(),b.getId()}, conn); 
		ConnectionUtil.close(conn); 
	} 
 
}