getPhotoByUserId(Integer id) {Connection conn = null;PreparedStatement ps = null;FileInputStream in = null;ResultSet rs = null;ArrayList userPhotos = new ArrayList();try {conn = DBUtil.getConn();//String sql = "select * from photo where id = " + id;String sql = "select userid, photoname, photourl from userphoto where userid = " + id;ps = conn.prepareStatement(sql);rs = ps.executeQuery(sql);while (rs.next()) {UserPhoto userPhoto = new UserPhoto(rs.getInt(1),rs.getString(2),rs.getString(3));userPhotos.add(userPhoto);}} catch (Exception e) {e.printStackTrace();} finally {DBUtil.closeConn(conn);if (null != ps) {try {ps.close();} catch (SQLException e) {e.printStackTrace();}}}return userPhotos;}/*** 插入用户,返回用户id(主键)** @param userInfo* @return*/@Overridepublic Integer addUser(UserInfo userInfo) {Connection conn = null;PreparedStatement ps = null;Integer ansId = null;try {conn = DBUtil.getConn();String sql = "insert into userinfo (username,birthday) values(?,?)";ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);ps.setString(1, userInfo.getUsername());ps.setObject(2, userInfo.getBirthday());int count = ps.executeUpdate();if (count > 0) {System.out.println("插入成功!");ResultSet rs = ps.getGeneratedKeys();if (rs.next()) {//获取主键,设置了主键自增ansId = rs.getInt(1);}} else {System.out.println("插入失败!");}} catch (Exception e) {e.printStackTrace();} finally {DBUtil.closeConn(conn);if (null != ps) {try {ps.close();} catch (SQLException e) {e.printStackTrace();}}}return ansId;}/*** 根据要求查看用户* @param name* @param startDate* @param endDate* @return*/@Overridepublic ArrayList