Search in sources :

Example 46 with DatabaseException

use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.

the class GenericAttachmentDAO method selectQuotaLimitByGroup.

/**
	 * @see net.jforum.dao.AttachmentDAO#selectQuotaLimit()
	 */
public QuotaLimit selectQuotaLimitByGroup(int groupId) {
    QuotaLimit ql = null;
    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("AttachmentModel.selectQuotaLimitByGroup"));
        p.setInt(1, groupId);
        rs = p.executeQuery();
        if (rs.next()) {
            ql = this.getQuotaLimit(rs);
        }
        return ql;
    } 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) QuotaLimit(net.jforum.entities.QuotaLimit) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 47 with DatabaseException

use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.

the class GenericAttachmentDAO method addExtensionGroup.

/**
	 * @see net.jforum.dao.AttachmentDAO#addExtensionGroup(net.jforum.entities.AttachmentExtensionGroup)
	 */
public void addExtensionGroup(AttachmentExtensionGroup g) {
    PreparedStatement p = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("AttachmentModel.addExtensionGroup"));
        p.setString(1, g.getName());
        p.setInt(2, g.isAllow() ? 1 : 0);
        p.setString(3, g.getUploadIcon());
        p.setInt(4, g.getDownloadMode());
        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 48 with DatabaseException

use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.

the class GenericAttachmentDAO method removeQuotaLimit.

/**
	 * @see net.jforum.dao.AttachmentDAO#removeQuotaLimit(java.lang.String[])
	 */
public void removeQuotaLimit(String[] ids) {
    PreparedStatement p = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("AttachmentModel.removeQuotaLimit"));
        for (int i = 0; i < ids.length; i++) {
            p.setInt(1, Integer.parseInt(ids[i]));
            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 49 with DatabaseException

use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.

the class GenericAttachmentDAO method isPhysicalDownloadMode.

public boolean isPhysicalDownloadMode(int extensionGroupId) {
    boolean result = true;
    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("AttachmentModel.isPhysicalDownloadMode"));
        p.setInt(1, extensionGroupId);
        rs = p.executeQuery();
        if (rs.next()) {
            result = (rs.getInt("download_mode") == 2);
        }
        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 50 with DatabaseException

use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.

the class GenericAttachmentDAO method selectQuotaLimit.

/**
	 * @see net.jforum.dao.AttachmentDAO#selectQuotaLimit()
	 */
public List selectQuotaLimit() {
    List l = new ArrayList();
    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("AttachmentModel.selectQuotaLimit"));
        rs = p.executeQuery();
        while (rs.next()) {
            l.add(this.getQuotaLimit(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) ArrayList(java.util.ArrayList) List(java.util.List) 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