• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing Database
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing Database


  • Subject: Re: Accessing Database
  • From: Owen Jones <email@hidden>
  • Date: Mon, 06 Jan 2003 08:01:02 -0500
  • Organization: York University

Riaz;

Riaz Lalehzari wrote:
Hello,

I have been trying for some time to make a simple program that can read and update fields from a database. But I always get an NSForwardException error.(below)

"Error:  com.webobjects.foundation.NSForwardException"

Who knows what this exception is for? I've looked it up in the online documentation but its description didn't exactly clarify things for me.

I believe that this is a holdover from previous versions of WO (i.e. < 5.x) and was used to wrap an Objective-C exception to be passed to Java. Old code that looks for this exception would be broken if it was simply eliminated.


The error happens when I call this method:

public boolean verifyLogin() {

//if the person is not valid, then reload the same page with a message
//if the person is valid, then redirect them to their personalized menu
//idNumber2 = Integer.parseInt(username_S);
String validUser = "no";


       EOEditingContext ec = new EOEditingContext();

// Create "guest" user, if not yet defined
//'Person_C' is my class with all the 'setUsername()' set..()etc
try
{ //Java Class Name of entity, key for the query, Value to look for
guest = (Person_C) EOUtilities.objectMatchingKeyAndValue(ec,"Users","username", "guest");
}
catch (EOObjectNotAvailableException exception1) //if this person does not exist then make a guest user
{
guest = new Person_C();
guest.setUsername("guest"); // eg. (public void setPassword(String value) { takeStoredValueForKey(value, "password"); })
guest.setPassword("guestPass");
ec.insertObject(guest);
// save changes permanently in database
ec.saveChanges();
}


// Search database for valid student
Object searchLogin = (username_S != null) ? (Object)username_S : (Object)NSKeyValueCoding.NullValue;


try
{
Person_C found = (Person_C) EOUtilities.objectMatchingKeyAndValue(ec,"Users","username",searchLogin);
if (found.password().equals(password_S)) {
return true;
}
}
catch (EOUtilities.MoreThanOneException ex)
{
return false;
}
catch (EOObjectNotAvailableException exception3)
{
return false;
}


       return false;
   }
}

I can't really find what is the problem with my code. My database only has one entity (Users) and 4 fields, (two of which are Primary keys (maybe that is the problem?))


It may help to catch the exception ("catch NSForwardException") and print out any associated messages and also do a stack dump at the same time - this will at least show you what EOF methods had been called and should narrow down the possible causes.


I log stack traces to the NSLog file thusly:

   ...
   catch ( NSForwardException anException {
      NSLog.PrintStreamLogger err = (NSLog.PrintStreamLogger)NSLog.err;
      anException.printStackTrace(err.printStream()); // stack trace is always useful in the log
   }



_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


--
                                Regards, Owen Jones

------------ http://yucc.yorku.ca/~ojones -------------
---------- SETI@Home Stats: 4853WU/5.69yrs -----------
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Accessing Database (From: "Riaz Lalehzari" <email@hidden>)

  • Prev by Date: Re: WODisplayGroup and insert
  • Next by Date: EOModel Many-To-Many Not Sychronising In myApplication
  • Previous by thread: Accessing Database
  • Next by thread: More Info on Error
  • Index(es):
    • Date
    • Thread