-
1. Re: Can not insert records properly
gorges Sep 21, 2003 3:18 AM (in response to gorges)I found that It's a problem of my JSP
-
2. Re: Can not insert records properly
jonlee Sep 21, 2003 3:25 AM (in response to gorges)The problem is most likely with your SQL, not with JBoss.
You insert a record even if there is an existing record. There is no check to prevent this. You need to have checked whether there is an existing record and based on the result, insert or update accordingly. By not having a primary key or restriction on an existing "matching" record, there is no exception if you do insert an identical copy. -
3. Re: Can not insert records properly
gorges Sep 21, 2003 6:01 AM (in response to gorges)Below is my JSP.It managies the relationship between the role and the permission of the role.Role_PermMan is the JavaBean to carry out the function.In which permExists() determines if the role already has the permission,assignPerm() assigns a permission to a role,revokePerm() revokes a permission from a role.
The "actionType" is used to determine what kind of action to take.
Sometimes,it just insert one record;but sometimes it insert two same records.This seems completely random.I'm confused.
<jsp:useBean id="hasConPerms" scope="page" class="SecurityMan.Role_PermMan" />
<%
String a=request.getParameter("actionType");
String role=(String)session.getAttribute("mRole1");
if(a.equals("grant")){
String grant=(String)request.getParameter("allcperms");
if(hasConPerms.permExists(role,grant)){
%>
The Role already has the permission!
<%
}
else
{
hasConPerms.assignPerm(role,grant);
%>
The permission has been assigned to the role!
<%
}
}
else if(a.equals("revoke")){
String revoke=(String)request.getParameter("hascperms");
hasConPerms.revokePerm(role,revoke);
%>
The permission has been revoked form the role!
<%
}
%>