use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericPostDAO method selectLatestByForumForRSS.
public List selectLatestByForumForRSS(int forumId, int limit) {
List l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.selectLatestByForumForRSS"));
p.setInt(1, forumId);
p.setInt(2, limit);
rs = p.executeQuery();
while (rs.next()) {
Post post = this.buildPostForRSS(rs);
l.add(post);
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
return l;
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericPostDAO method updatePostsTable.
protected void updatePostsTable(Post post) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.updatePost"));
p.setInt(1, post.getTopicId());
p.setInt(2, post.getForumId());
p.setInt(3, post.isBbCodeEnabled() ? 1 : 0);
p.setInt(4, post.isHtmlEnabled() ? 1 : 0);
p.setInt(5, post.isSmiliesEnabled() ? 1 : 0);
p.setInt(6, post.isSignatureEnabled() ? 1 : 0);
p.setTimestamp(7, new Timestamp(System.currentTimeMillis()));
p.setInt(8, post.getEditCount() + 1);
p.setString(9, post.getUserIp());
p.setInt(10, post.getId());
p.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericPostDAO method countPreviousPosts.
/**
* @see net.jforum.model.PostModel#countPreviousPosts(int)
*/
public int countPreviousPosts(int postId) {
int total = 0;
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.countPreviousPosts"));
p.setInt(1, postId);
p.setInt(2, postId);
rs = p.executeQuery();
if (rs.next()) {
total = rs.getInt(1);
}
return total;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericTopicDAO method getMinPostId.
/**
* @see net.jforum.dao.TopicDAO#getMinPostId(int)
*/
public int getMinPostId(int topicId) {
int id = -1;
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.getMinPostId"));
p.setInt(1, topicId);
ResultSet rs = p.executeQuery();
if (rs.next()) {
id = rs.getInt("post_id");
}
return id;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericTopicDAO method subscribeUsers.
/**
* @see net.jforum.dao.TopicDAO#subscribeUsers(int, java.util.List)
*/
public void subscribeUsers(int topicId, List users) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.subscribeUser"));
p.setInt(1, topicId);
for (Iterator iter = users.iterator(); iter.hasNext(); ) {
int userId = ((User) iter.next()).getId();
p.setInt(2, userId);
p.executeUpdate();
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
Aggregations