aspose file tools*
The moose likes JForum and the fly likes it seem have a little question at SecurityCommon -> executeAddRole() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » JForum
Bookmark "it seem have a little question at SecurityCommon -> executeAddRole()" Watch "it seem have a little question at SecurityCommon -> executeAddRole()" New topic
Author

it seem have a little question at SecurityCommon -> executeAddRole()

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
try {
if (supportAutoGeneratedKeys) {
p = JForumExecutionContext.getConnection().prepareStatement(sql,
Statement.RETURN_GENERATED_KEYS);
} else {
p = JForumExecutionContext.getConnection().prepareStatement(sql);
}

p.setInt(1, id);
p.setString(2, role.getName());

// there no the third parameter values!!!

p.executeUpdate();

if (roleValues != null) {
int roleId = -1;

if (supportAutoGeneratedKeys) {
rs = p.getGeneratedKeys();
rs.next();
roleId = rs.getInt(1);
} else {
p = JForumExecutionContext.getConnection().prepareStatement(
autoKeysQuery);
rs = p.executeQuery();
if (rs.next()) {
roleId = rs.getInt(1);
}
}
rs.close();
rs = null;
p.close();
p = null;

if (roleId == -1) {
throw new SQLException("Could not obtain the latest role id");
}

p = JForumExecutionContext.getConnection().prepareStatement(
SystemGlobals.getSql("PermissionControl.addRoleValues"));

for (Iterator iter = roleValues.iterator(); iter.hasNext(); ) {
RoleValue rv = (RoleValue) iter.next();

p.setInt(1, roleId);
p.setString(2, rv.getValue());

p.executeUpdate(); // when debug here throw err !!
}
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}

the sql have three parameter but before p.executeUpdate(); only set two parameter

:
INSERT INTO jforum_roles (role_id, group_id, name, role_type ) VALUES (jforum_roles_seq.nextval, ?, ?, ?)

p.setInt(1, id);
p.setString(2, role.getName());




[originally posted on jforum.net by jyhcyd]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Which version of SecurityCommon you use?

There is version of SecurityCommon for 2.1.5/2.1.6 jforum
https://jforum.dev.java.net/source/browse/jforum/src/net/jforum/dao/generic/security/SecurityCommon.java?rev=1.5&view=markup


[originally posted on jforum.net by Serge Maslyukov]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
i use the file SecurityCommon which i get from CVS today

SecurityCommon.java edition 1.11 Fir Aug 25 01:04:36 2006


[originally posted on jforum.net by jyhcyd]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
i use Oracle9i whether Jforum not sustain Oracle ??
[originally posted on jforum.net by jyhcyd]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Sorry, we changed the security code, but I forgot to update some sql scripts.

Try fetching from the cvs again.. it should be fixed now.

Rafael
[originally posted on jforum.net by Rafael Steil]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
thanks!!
[originally posted on jforum.net by jyhcyd]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: it seem have a little question at SecurityCommon -> executeAddRole()