Here is the bean code. I would expect the nonunique error to be caught by the SQLException catch clause but it isn't. 
 
public UserMasterPK ejbCreate(String name,String email,String pw,String administrator,String defaultUser,String defaultResponse) throws CreateException,RemoteException
 {
  this.id = AutoNumberFactory.getNextNumber("user_master");
  this.name=name;
  this.email=email;
  this.pw=pw;
  this.administrator=administrator;
  this.defaultUser=defaultUser;
  this.defaultResponse=defaultResponse;
 
  final String STATEMENT = "INSERT INTO user_master (id, name, email, pw, administrator, default_user, default_response) VALUES (?,?,?,?,?,?,?)";
  Connection conn = null;
  PreparedStatement ps = null;
 
  try
  {
   conn = SQLUtil.getConnection(datasource);
   ps = conn.prepareStatement(STATEMENT);
   ps.setInt(1, id);
   ps.setString(2, name);
   ps.setString(3, email);
   ps.setString(4, pw);
   ps.setString(5, administrator);
   ps.setString(6, defaultUser);
   ps.setString(7, defaultResponse);
   if(ps.executeUpdate()!=1)
   {
    throw new CreateException("user_master ejbCreate failed");
   }
  }
  catch(SQLException x)
  {
   throw new EJBException(x);
  }
  catch(NamingException x)
  {
   throw new EJBException(x);
  }
  finally
  {
   if(ps != null)
    try {ps.close();} catch(Exception e) {}
   if(conn != null)
    try {conn.close();} catch(SQLException e) {}
  }
  UserMasterPK pk = new UserMasterPK(id);
  return pk;
 
    }

Reply via email to