1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| package com.OY.online.jdbc.DAO;
import com.OY.online.jdbc.bean.Customer;
import java.sql.Connection; import java.util.List;
public class CustomerDAOImpI extends BaseDAO<Customer> implements CustomerDAO {
@Override public void insert(Connection conn, Customer cust) { String sql = "insert into customers(name, email,birth)values(?,?,?)"; Update(conn,sql,cust.getName(),cust.getEmail(),cust.getBirth()); }
@Override public void deleteByID(Connection conn, int id) { String sql = "delete from customers where id =?"; Update(conn, sql ,id); }
@Override public void update(Connection conn, Customer cust) { String sql = "update customers set name =?, email = ?, birth =? where id =?"; Update(conn,sql,cust.getName(),cust.getEmail(),cust.getBirth(),cust.getId()); }
@Override public Customer getConnectionById(Connection conn, int id) { String sql = "select id, name, email, birth from customers where id = ?";
Customer cust = getConnection(conn, sql, id); return cust; }
@Override public List<Customer> getAll(Connection conn) { String sql ="select id, name, email, birth from customers "; List<Customer> list = getConnectionList(conn, sql); return list; }
@Override public Long getCount(Connection conn) { String sql = "select count(*) from customers"; Object value = getValue(conn, sql); return (Long) value; } }
|