Search in sources :

Example 51 with DatabaseException

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);
    }
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 52 with DatabaseException

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);
    }
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 53 with DatabaseException

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);
    }
}
Also used : PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 54 with DatabaseException

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);
    }
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 55 with DatabaseException

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);
    }
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) List(java.util.List) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException)

Aggregations

DatabaseException (net.jforum.exceptions.DatabaseException)264 PreparedStatement (java.sql.PreparedStatement)255 SQLException (java.sql.SQLException)254 ResultSet (java.sql.ResultSet)138 List (java.util.List)64 ArrayList (java.util.ArrayList)63 Timestamp (java.sql.Timestamp)17 User (net.jforum.entities.User)15 Iterator (java.util.Iterator)12 Post (net.jforum.entities.Post)9 Date (java.util.Date)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Topic (net.jforum.entities.Topic)8 Connection (java.sql.Connection)5 Bookmark (net.jforum.entities.Bookmark)5 KarmaStatus (net.jforum.entities.KarmaStatus)4 SimpleDateFormat (java.text.SimpleDateFormat)3 PrivateMessage (net.jforum.entities.PrivateMessage)3 Ranking (net.jforum.entities.Ranking)3