public CustomerEntity insert(CustomerEntity ce) throws SQLException { /*CREATE TABLE customer (cus_id VARCHAR(50), * cus_name VARCHAR(50), cus_address VARCHAR(100),cus_linkMan varchar(30), cus_linkManPhone varchar (50));*/ String sql = "insert into customer values(?,?,?,?,?)"; this.ps = this.conn.prepareStatement(sql); this.ps.setString(1, UuidUtil.getUUID()); this.ps.setString(2, ce.getCusName()); this.ps.setString(3, ce.getCusAddress()); this.ps.setString(4, ce.getCusLinkMan()); this.ps.setString(5, ce.getCusLinkManPhone()); this.ps.executeUpdate(); return ce; }
public List<CustomerEntity> queryList() throws SQLException { List<CustomerEntity> list = new ArrayList<CustomerEntity>(); String sql = " select * from kh "; this.ps = this.conn.prepareStatement(sql); this.rs = this.ps.executeQuery(); while (this.rs.next()) { CustomerEntity ce = new CustomerEntity(); ce.setCusId(this.rs.getString(1)); ce.setCusName(this.rs.getString(2)); ce.setCusAddress(this.rs.getString(3)); ce.setCusLinkMan(this.rs.getString(4)); ce.setCusLinkManPhone(this.rs.getString(5)); list.add(ce); } return list; }