public int updUser(UserEntity user) {
   Connection conn = null;
   try {
     conn = JDBCUtils.getConn();
     String isql =
         "update user set kind=?,shortTitle=?,specialService=?,author=?,origin=?,"
             + "companyAddress=?,officeCompany=?,companyNumber=?,servicesType=?,respectiveIndustries=?,companyLeader=?,title=?where id = ? ";
     PreparedStatement pstmt = conn.prepareStatement(isql);
     pstmt.setString(1, user.getKind());
     pstmt.setString(2, user.getShortTitle());
     pstmt.setString(3, user.getSpecialService());
     pstmt.setDouble(4, user.getAuthor());
     pstmt.setString(5, user.getOrigin());
     pstmt.setString(6, user.getCompanyAddress());
     pstmt.setString(7, user.getOfficeCompany());
     pstmt.setInt(8, user.getCompanyNumber());
     pstmt.setString(19, user.getServicesType());
     pstmt.setString(10, user.getRespectiveIndustries());
     pstmt.setString(11, user.getCompanyLeader());
     pstmt.setString(12, user.getTitle());
     pstmt.setString(13, user.getId());
     return pstmt.executeUpdate();
   } catch (JDBCUTilsException e) {
     e.printStackTrace();
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     try {
       JDBCUtils.close(conn);
     } catch (SQLException e) {
       e.printStackTrace();
     }
   }
   return 0;
 }
 public int addUser(UserEntity user) throws SQLException {
   Connection conn = null;
   try {
     // check 唯一性
     conn = JDBCUtils.getConn();
     String isql =
         "insert into user (id,username,password,kind,shortTitle,specialService,author,origin,"
             + "companyAddress,officeCompany,companyNumber,servicesType,respectiveIndustries,companyLeader,title,createdate) "
             + " values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
     PreparedStatement pstmt = conn.prepareStatement(isql);
     pstmt.setString(1, user.getId());
     pstmt.setString(2, user.getUsername());
     pstmt.setString(3, user.getPassword());
     pstmt.setString(4, user.getKind());
     pstmt.setString(5, user.getShortTitle());
     pstmt.setString(6, user.getSpecialService());
     pstmt.setDouble(7, user.getAuthor());
     pstmt.setString(8, user.getOrigin());
     pstmt.setString(9, user.getCompanyAddress());
     pstmt.setString(10, user.getOfficeCompany());
     pstmt.setInt(11, user.getCompanyNumber());
     pstmt.setString(12, user.getServicesType());
     pstmt.setString(13, user.getRespectiveIndustries());
     pstmt.setString(14, user.getCompanyLeader());
     pstmt.setString(15, user.getTitle());
     pstmt.setDate(16, new Date(System.currentTimeMillis()));
     return pstmt.executeUpdate();
   } finally {
     try {
       JDBCUtils.close(conn);
     } catch (SQLException e) {
       e.printStackTrace();
     }
   }
 }
 private UserEntity getEntity(ResultSet rs) throws SQLException {
   UserEntity user = new UserEntity();
   user.setId(rs.getString("id"));
   user.setUsername(rs.getString("username"));
   user.setPassword(rs.getString("password"));
   user.setKind(rs.getString("kind"));
   user.setShortTitle(rs.getString("shortTitle"));
   user.setSpecialService(rs.getString("specialService"));
   user.setAuthor(rs.getDouble("Author"));
   user.setOrigin(rs.getString("origin"));
   user.setCompanyAddress(rs.getString("companyAddress"));
   user.setOfficeCompany(rs.getString("officeCompany"));
   user.setCompanyNumber(rs.getInt("companyNumber"));
   user.setServicesType(rs.getString("servicesType"));
   user.setRespectiveIndustries(rs.getString("respectiveIndustries"));
   user.setCompanyLeader(rs.getString("companyLeader"));
   user.setTitle(rs.getString("title"));
   return user;
 }