use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericKarmaDAO method getUserKarma.
/**
* @see net.jforum.dao.KarmaDAO#selectKarmaStatus(int)
*/
public KarmaStatus getUserKarma(int userId) {
KarmaStatus status = new KarmaStatus();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("KarmaModel.getUserKarma"));
p.setInt(1, userId);
rs = p.executeQuery();
if (rs.next()) {
status.setKarmaPoints(Math.round(rs.getDouble("user_karma")));
}
return status;
} 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 GenericKarmaDAO method userCanAddKarma.
/**
* @see net.jforum.dao.KarmaDAO#userCanAddKarma(int, int)
*/
public boolean userCanAddKarma(int userId, int postId) {
boolean status = true;
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("KarmaModel.userCanAddKarma"));
p.setInt(1, postId);
p.setInt(2, userId);
rs = p.executeQuery();
if (rs.next()) {
status = rs.getInt(1) < 1;
}
return status;
} 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 GenericLuceneDAO method getPostsToIndex.
/**
* @see net.jforum.dao.LuceneDAO#getPostsToIndex(LuceneReindexArgs, int, int)
*/
public List getPostsToIndex(int fromPostId, int toPostId) {
List l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("SearchModel.getPostsToIndexForLucene"));
p.setInt(1, fromPostId);
p.setInt(2, toPostId);
rs = p.executeQuery();
while (rs.next()) {
l.add(this.makePost(rs));
}
} 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 GenericMailIntegrationDAO method update.
/**
* @see net.jforum.dao.MailIntegrationDAO#update(net.jforum.entities.MailIntegration)
*/
public void update(MailIntegration integration) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("MailIntegration.update"));
this.prepareForSave(integration, p);
p.setInt(8, integration.getForumId());
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 GenericMailIntegrationDAO method add.
/**
* @see net.jforum.dao.MailIntegrationDAO#add(net.jforum.entities.MailIntegration)
*/
public void add(MailIntegration integration) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("MailIntegration.add"));
this.prepareForSave(integration, p);
p.executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
Aggregations