use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericAttachmentDAO method updateQuotaLimit.
/**
* @see net.jforum.dao.AttachmentDAO#updateQuotaLimit(net.jforum.entities.QuotaLimit)
*/
public void updateQuotaLimit(QuotaLimit limit) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("AttachmentModel.updateQuotaLimit"));
p.setString(1, limit.getDescription());
p.setInt(2, limit.getSize());
p.setInt(3, limit.getType());
p.setInt(4, limit.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 GenericAttachmentDAO method addExtension.
/**
* @see net.jforum.dao.AttachmentDAO#addExtension(net.jforum.entities.AttachmentExtension)
*/
public void addExtension(AttachmentExtension extension) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("AttachmentModel.addExtension"));
p.setInt(1, extension.getExtensionGroupId());
p.setString(2, extension.getComment());
p.setString(3, extension.getUploadIcon());
p.setString(4, extension.getExtension().toLowerCase());
p.setInt(5, extension.isAllow() ? 1 : 0);
p.executeUpdate();
} catch (SQLException ex) {
throw new DatabaseException(ex);
} finally {
DbUtils.close(p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericBanlistDAO method insert.
/**
* @see net.jforum.dao.BanlistDAO#insert(net.jforum.entities.Banlist)
*/
public void insert(Banlist b) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BanlistModel.insert"));
p.setInt(1, b.getUserId());
p.setString(2, b.getIp());
p.setString(3, b.getEmail());
this.setAutoGeneratedKeysQuery(SystemGlobals.getSql("BanlistModel.lastGeneratedBanlistId"));
int id = this.executeAutoKeysQuery(p);
b.setId(id);
} catch (Exception e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericBannerDAO method canDelete.
public boolean canDelete(int bannerId) {
boolean result = true;
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BannerDAO.canDelete"));
p.setInt(1, bannerId);
rs = p.executeQuery();
if (!rs.next() || rs.getInt("total") < 1) {
result = false;
}
return result;
} 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 GenericBookmarkDAO method selectByUser.
/**
* @see net.jforum.dao.BookmarkDAO#selectByUser(int)
*/
public List selectByUser(int userId) {
List l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.selectAllFromUser"));
p.setInt(1, userId);
rs = p.executeQuery();
while (rs.next()) {
l.add(this.getBookmark(rs));
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
Aggregations