jforum2 icon indicating copy to clipboard operation
jforum2 copied to clipboard

SQL Exceptions using PostgreSQL in 2.1.9

Open jeffoh opened this issue 14 years ago • 4 comments

There are three SQL Exceptions in 2.1.9 when using Postgres. I have suggested fixes for each

net/jforum/dao/generic/GenericForumDao.java:

/**
 * @see net.jforum.dao.ForumDAO#getModeratorList(int)
 */
public List getModeratorList(int forumId)
{
    List l = new ArrayList();

    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(
                SystemGlobals.getSql("ForumModel.getModeratorList"));
        //  OLD: p.setInt(1, forumId);
        p.setString(1, String.valueOf(forumId));

        rs = p.executeQuery();

        while (rs.next()) {
            ModeratorInfo mi = new ModeratorInfo();

            mi.setId(rs.getInt("id"));
            mi.setName(rs.getString("name"));

            l.add(mi);
        }

        return l;
    }
    catch (SQLException e) {
        throw new DatabaseException(e);
    }
    finally {
        DbUtils.close(rs, p);
    }
}

WEB-INF/config/database/postgresql/postgresql.sql:

# #############
# ForumModel
# #############
ForumModel.lastGeneratedForumId = SELECT CURRVAL('jforum_forums_seq');

#
#  Add the following two queries
#
ForumModel.statsFirstPostTime = SELECT MIN(post_time) FROM jforum_posts     WHERE post_time > timestamp '01-01-01 00:00:00'
ForumModel.statsFirstRegisteredUserTime = SELECT MIN(user_regdate) FROM jforum_users WHERE user_regdate > timestamp '01-01-01 00:00:00'

jeffoh avatar Oct 30 '10 15:10 jeffoh

Thanks - this works great. I appreciate it.

gregopad39 avatar Nov 17 '10 19:11 gregopad39

I can't find the 2.1.9 source code. Do you have class file I can download for the fix? Thanks in advance!

rkhlin avatar Feb 15 '11 13:02 rkhlin

Don't bother, I found the code. Cheers

rkhlin avatar Feb 15 '11 13:02 rkhlin

Muchas gracias, me pasaba lo mismo

dmarin avatar Feb 22 '11 15:02 dmarin