• 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
Accessing Database
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accessing Database


  • Subject: Accessing Database
  • From: "Riaz Lalehzari" <email@hidden>
  • Date: Mon, 06 Jan 2003 04:48:19 +0000

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.

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?))



_________________________________________________________________
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.

  • Follow-Ups:
    • Re: Accessing Database
      • From: Owen Jones <email@hidden>
  • Prev by Date: Quick question
  • Next by Date: Re: WO Tutorial - Component Communication
  • Previous by thread: Re: WO Tutorial - Component Communication
  • Next by thread: Re: Accessing Database
  • Index(es):
    • Date
    • Thread