use of net.jforum.exceptions.DatabaseException in project jforum2 by rafaelsteil.
the class GenericGroupDAO method selectById.
/**
* @see net.jforum.dao.GroupDAO#selectById(int)
*/
public Group selectById(int groupId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("GroupModel.selectById"));
p.setInt(1, groupId);
rs = p.executeQuery();
Group g = new Group();
if (rs.next()) {
g = this.getGroup(rs);
}
return g;
} 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 GenericGroupDAO method canDelete.
/**
* @see net.jforum.dao.GroupDAO#canDelete(int)
*/
public boolean canDelete(int groupId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("GroupModel.canDelete"));
p.setInt(1, groupId);
boolean status = false;
rs = p.executeQuery();
if (!rs.next() || rs.getInt("total") < 1) {
status = true;
}
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 GenericGroupDAO method addNew.
/**
* @see net.jforum.dao.GroupDAO#addNew(net.jforum.entities.Group)
*/
public void addNew(Group group) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("GroupModel.addNew"));
p.setString(1, group.getName());
p.setString(2, group.getDescription());
p.setInt(3, group.getParentId());
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 GenericGroupDAO method selectUsersIds.
/**
* @see net.jforum.dao.GroupDAO#selectUsersIds(int)
*/
public List selectUsersIds(int groupId) {
ArrayList l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("GroupModel.selectUsersIds"));
p.setInt(1, groupId);
rs = p.executeQuery();
while (rs.next()) {
l.add(new Integer(rs.getInt("user_id")));
}
return l;
} 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 GenericGroupDAO method delete.
/**
* @see net.jforum.dao.GroupDAO#delete(int)
*/
public void delete(int groupId) {
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("GroupModel.delete"));
p.setInt(1, groupId);
p.executeUpdate();
GroupSecurityDAO securityDao = DataAccessDriver.getInstance().newGroupSecurityDAO();
securityDao.deleteAllRoles(groupId);
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
Aggregations