Package cn.edu.zju.acm.onlinejudge.persistence

Examples of cn.edu.zju.acm.onlinejudge.persistence.PersistenceException


                ps.setString(3, post.getContent());
                ps.setLong(4, user);
                ps.setTimestamp(5, new Timestamp(new Date().getTime()));
                ps.setLong(6, post.getId());
                if (ps.executeUpdate() == 0) {
                    throw new PersistenceException("no such post");
                }
            } finally {
                Database.dispose(ps);
            }
        } catch (PersistenceException pe) {
            throw pe;
        } catch (SQLException e) {
            throw new PersistenceException("Failed to update post.", e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here


                ps = conn.prepareStatement(ForumPersistenceImpl.DELETE_POST);
                ps.setLong(1, user);
                ps.setTimestamp(2, new Timestamp(new Date().getTime()));
                ps.setLong(3, id);
                if (ps.executeUpdate() == 0) {
                    throw new PersistenceException("no such post");
                }
            } finally {
                Database.dispose(ps);
            }
        } catch (PersistenceException pe) {
            throw pe;
        } catch (SQLException e) {
            throw new PersistenceException("Failed to delete post.", e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here

                }
            } finally {
                Database.dispose(ps);
            }
        } catch (SQLException e) {
            throw new PersistenceException("Failed to get the post with id " + id, e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here

                return posts;
            } finally {
                Database.dispose(ps);
            }
        } catch (SQLException e) {
            throw new PersistenceException("Failed to get the posts", e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here

            } finally {
                Database.dispose(ps);
            }

        } catch (SQLException e) {
            throw new PersistenceException("Failed to create user.", e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here

            } finally {
                Database.dispose(ps);
            }

        } catch (SQLException e) {
            throw new PersistenceException("Failed to create user.", e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here

                    ps.executeUpdate();
                } finally {
                    Database.dispose(ps);
                }
            } catch (SQLException e) {
                throw new PersistenceException("Failed to update user.", e);
            } finally {
                Database.dispose(conn);
            }
        } else {
            Connection conn = null;
            try {
                conn = Database.createConnection();
                PreparedStatement ps = null;
                try {
                    ps = conn.prepareStatement(UserPersistenceImpl.UPDATE_USER);
                    ps.setString(1, profile.getHandle());
                    ps.setString(2, profile.getPassword());
                    ps.setString(3, profile.getEmail());
                    ps.setString(4, profile.getFirstName());
                    ps.setString(5, profile.getLastName());
                    ps.setString(6, profile.getAddressLine1());
                    ps.setString(7, profile.getAddressLine2());
                    ps.setString(8, profile.getCity());
                    ps.setString(9, profile.getState());
                    ps.setLong(10, profile.getCountry().getId());
                    ps.setString(11, profile.getZipCode());
                    ps.setString(12, profile.getPhoneNumber());
                    ps.setTimestamp(13, new Timestamp(profile.getBirthDate().getTime()));
                    ps.setString(14, "" + profile.getGender());
                    ps.setString(15, profile.getSchool());
                    ps.setString(16, profile.getMajor());
                    ps.setBoolean(17, profile.isGraduateStudent());
                    ps.setInt(18, profile.getGraduationYear());
                    ps.setString(19, profile.getStudentNumber());
                    ps.setBoolean(20, profile.isConfirmed());
                    ps.setLong(21, user);
                    ps.setTimestamp(22, new Timestamp(new Date().getTime()));
                    ps.setString(23, profile.getNickName());
                    ps.setLong(24, profile.getId());
                    ps.executeUpdate();
                } finally {
                    Database.dispose(ps);
                }
            } catch (SQLException e) {
                throw new PersistenceException("Failed to update user.", e);
            } finally {
                Database.dispose(conn);
            }
        }
    }
View Full Code Here

                ps = conn.prepareStatement(UserPersistenceImpl.DELETE_USER);
                ps.setLong(1, user);
                ps.setTimestamp(2, new Timestamp(new Date().getTime()));
                ps.setLong(3, id);
                if (ps.executeUpdate() == 0) {
                    throw new PersistenceException("No such user profile.");
                }
            } finally {
                Database.dispose(ps);
            }
        } catch (PersistenceException e) {
            throw e;
        } catch (SQLException e) {
            throw new PersistenceException("Failed to delete user profile.", e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here

                }
            } finally {
                Database.dispose(ps);
            }
        } catch (SQLException e) {
            throw new PersistenceException("Failed to get the user profile with id " + id, e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here

                }
            } finally {
                Database.dispose(ps);
            }
        } catch (SQLException e) {
            throw new PersistenceException("Failed to get the user profile with handle " + handle, e);
        } finally {
            Database.dispose(conn);
        }
    }
View Full Code Here

TOP

Related Classes of cn.edu.zju.acm.onlinejudge.persistence.PersistenceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.