关系管理系统:CustomerDaoimpl中添加用户代码update()

public void update(Customer c){
        Connection conn = null;
        PreparedStatement st = null;
        ResultSet rs = null;
        try{
            conn = JdbcUtils.getConnection();
            String sql = "update customer set name=?,gender=?,birthday=?,cellphone=?,email=?,preference=?,type=?,description=? where id=?";
            st = conn.prepareStatement(sql);
            st.setString(1, c.getName());
            st.setString(2, c.getGender());
            st.setDate(3, new java.sql.Date(c.getBirthday().getTime()));
            st.setString(4, c.getCellphone());
            st.setString(5, c.getEmail());
            st.setString(6, c.getPreference());
            st.setString(7, c.getType());
            st.setString(8, c.getDescription());
            st.setString(9, c.getId());
            
            st.executeUpdate();
        }catch (Exception e) {
            throw new DaoException(e);
        }finally{
            JdbcUtils.release(conn, st, rs);
        }    

 

posted @ 2013-07-07 11:03  亂舞春秋  阅读(231)  评论(0编辑  收藏  举报