use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericTreeGroupDAO method selectGroups.
/**
* @see net.jforum.dao.TreeGroupDAO#selectGroups(int)
*/
public List selectGroups(int parentId) {
List list = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TreeGroup.selectGroup"));
p.setInt(1, parentId);
rs = p.executeQuery();
while (rs.next()) {
GroupNode n = new GroupNode();
n.setName(rs.getString("group_name"));
n.setId(rs.getInt("group_id"));
list.add(n);
}
return list;
} 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 GenericUserDAO method decrementPosts.
/**
* @see net.jforum.dao.UserDAO#decrementPosts(int)
*/
public void decrementPosts(int userId) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("UserModel.decrementPosts"));
p.setInt(1, userId);
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 GenericUserDAO method setActive.
/**
* @see net.jforum.dao.UserDAO#setActive(int, boolean)
*/
public void setActive(int userId, boolean active) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("UserModel.activeStatus"));
p.setInt(1, active ? 1 : 0);
p.setInt(2, userId);
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 GenericUserDAO method validateLostPasswordHash.
/**
* @see net.jforum.dao.UserDAO#validateLostPasswordHash(java.lang.String, java.lang.String)
*/
public boolean validateLostPasswordHash(String email, String hash) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("UserModel.validateLostPasswordHash"));
p.setString(1, hash);
p.setString(2, email);
boolean status = false;
rs = p.executeQuery();
if (rs.next() && rs.getInt("valid") > 0) {
status = true;
this.writeLostPasswordHash(email, "");
}
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 GenericUserDAO method hasUsernameChanged.
/**
* @see net.jforum.dao.UserDAO#hasUsernameChanged(int, java.lang.String)
*/
public boolean hasUsernameChanged(int userId, String usernameToCheck) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("UserModel.getUsername"));
p.setString(1, usernameToCheck);
p.setInt(2, userId);
String dbUsername = null;
rs = p.executeQuery();
if (rs.next()) {
dbUsername = rs.getString("username");
}
boolean status = false;
if (!usernameToCheck.equals(dbUsername)) {
status = true;
}
return status;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
Aggregations