Dear Alexey Loubyansky,
I too having same problem actually i thought that i solved but it works due to i
created another primary key in second table.
userid is Primary key for One table and Foreign Key for 2nd table.I created the one
more Primary key in second table(sem) than i can store info from registration form but
when i want to use foreign key of second table to store info it does't work.
Servlet Code:
beanRemote =
home.create(fname,lname,dob,sex,userid,password,street,city,zipc,phone,email );
db = home.findByPrimaryKey(userid);
beanRemotes = homes.create(userid,dept,mno,sem );
dbs = homes.findByPrimaryKey(sem);
private boolean checkUSERID ( String userid, InitialContext context )
throws NamingException {
Object object = context.lookup("RegistrationEjb");
RegistrationHome home = ( RegistrationHome )
PortableRemoteObject
.narrow ( object, RegistrationHome.class );
try {
System.out.println("");
Registration data = home.findByPrimaryKey( userid );
if ( data!=null ) {
if ( data.getUserid().equals( userid ) ) {
return true;
}
} else {
return false;
}
} catch ( Exception exception ) {
return false;
}
return true;
}
private boolean checkSEM ( String sem, InitialContext context )
throws NamingException {
Object object = context.lookup("RegistrationspecificEjb");
RegistrationspecificHome home = ( RegistrationspecificHome )
PortableRemoteObject
.narrow ( object,
RegistrationspecificHome.class );
try {
System.out.println("");
Registrationspecific data = home.findByPrimaryKey( sem );
if ( data!=null ) {
if ( data.getSem().equals( sem ) ) {
return true;
}
} else {
return false;
}
} catch ( Exception exception ) {
return false;
}
return true;
}
ejb-code:
public interface RegistrationspecificHome extends EJBHome{
public static final String
COMP_NAME="java:comp/env/ejb/madadi/Registrationspecific";
public static final String JNDI_NAME="ejb/madadi/RegistrationspecificEjb";
public Registrationspecific create(String userid,String dept,String mno,String
sem) throws RemoteException, CreateException;
public Registrationspecific findByPrimaryKey(String sem) throws
FinderException, RemoteException;
public Registrationspecific findAll() throws FinderException, RemoteException;
public interface RegistrationHome extends EJBHome{
public static final String COMP_NAME="java:comp/env/ejb/madadi/Registration";
public static final String JNDI_NAME="ejb/madadi/RegistrationEjb";
public Registration create(String fname, String lname, String dob, String sex,
String userid, String password, String street, String city, String zipc, String phone,
String email) throws RemoteException, CreateException;
public Registration findByPrimaryKey(String userid) throws FinderException,
RemoteException;
public Registration findAll() throws FinderException, RemoteException;
}
public abstract class RegistrationspecificEjb implements EntityBean {
public abstract String getUserid();
public abstract String getDept();
public abstract String getMno();
public abstract String getSem();
public abstract void setUserid(String userid);
public abstract void setDept(String dept);
public abstract void setMno(String mno);
public abstract void setSem(String sem);
public String ejbCreate(String userid,String dept,String mno,String sem ) throws
RemoteException, CreateException
{
setUserid(userid);
setDept(dept);
setMno(mno);
setSem(sem);
return (null);
}
public abstract class RegistrationEjb implements EntityBean {
// Called by container after setEntityContext
// Use the abstract methods to set parameters
public abstract String getFname();
public abstract Strin