use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericTopicDAO method selectRecentTopics.
/**
* @see net.jforum.dao.TopicDAO#selectRecentTopics(int)
*/
public List selectRecentTopics(int limit) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.selectRecentTopicsByLimit"));
p.setInt(1, limit);
List list = this.fillTopicsData(p);
return list;
} 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 updateReadStatus.
/**
* @see net.jforum.dao.TopicDAO#updateReadStatus(int, int, boolean)
*/
public void updateReadStatus(int topicId, int userId, boolean read) {
if (this.isUserSubscribed(topicId, userId)) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.updateReadStatus"));
p.setInt(1, read ? 1 : 0);
p.setInt(2, topicId);
p.setInt(3, userId);
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 GenericTopicDAO method incrementTotalReplies.
/**
* @see net.jforum.dao.TopicDAO#incrementTotalReplies(int)
*/
public void incrementTotalReplies(int topicId) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.incrementTotalReplies"));
p.setInt(1, topicId);
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 GenericTopicDAO method setModerationStatus.
/**
* @see net.jforum.dao.TopicDAO#setModerationStatus(int, boolean)
*/
public void setModerationStatus(int forumId, boolean status) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.setModerationStatus"));
p.setInt(1, status ? 1 : 0);
p.setInt(2, forumId);
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 GenericTopicDAO method selectById.
/**
* @see net.jforum.dao.TopicDAO#selectById(int)
*/
public Topic selectById(int topicId) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.selectById"));
p.setInt(1, topicId);
Topic t = new Topic();
List l = this.fillTopicsData(p);
p = null;
if (l.size() > 0) {
t = (Topic) l.get(0);
}
return t;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
Aggregations