use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericForumDAO method incrementTotalTopics.
/**
* @see net.jforum.dao.ForumDAO#setTotalTopics(int)
*/
public void incrementTotalTopics(int forumId, int count) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.incrementTotalTopics"));
p.setInt(1, count);
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 GenericForumDAO method update.
/**
* @see net.jforum.dao.ForumDAO#update(net.jforum.entities.Forum)
*/
public void update(Forum forum) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.update"));
p.setInt(1, forum.getCategoryId());
p.setString(2, forum.getName());
p.setString(3, forum.getDescription());
p.setInt(4, forum.isModerated() ? 1 : 0);
p.setInt(5, forum.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 GenericForumDAO method getTotalMessages.
/**
* @see net.jforum.dao.ForumDAO#getTotalMessages()
*/
public int getTotalMessages() {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.totalMessages"));
rs = p.executeQuery();
if (rs.next()) {
return rs.getInt("total_messages");
}
return 0;
} 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 GenericForumDAO method removeSubscription.
public void removeSubscription(int forumId, int userId) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.removeSubscription"));
p.setInt(1, forumId);
p.setInt(2, 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 GenericForumDAO method selectAll.
/**
* @see net.jforum.dao.ForumDAO#selectAll()
*/
public List selectAll() {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("ForumModel.selectAll"));
List l = new ArrayList();
rs = p.executeQuery();
while (rs.next()) {
l.add(this.fillForum(rs));
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
Aggregations