Hi Subu,
u need to do something like this in your ejbCreate method for CMP
public CustomerPK ejbCreate(String custname, int age)
throws CreateException,
RemoteException
{
System.out.println(" In create of Cust");
this.custcode = getSeqCode();//This is the PK say..
this.custname = custname;
this.age = age;
return null;
}
private int getSeqCode()
{
try
{
Connection con = getConnection();
PreparedStatement ps = con.prepareStatement("select
testseq.nextval from dual");
ps.executeQuery();
ResultSet rs = ps.getResultSet();
int i = 0;
while (rs.next())
{
i = rs.getInt(1);
}
rs.close();
return i;
}
catch(Exception e)
{
e.printStackTrace();
return 0;
}
}
This will work. But I think there are lot other solutions for this ---
namely one followed by IAS. U can check the archive for those.
HTH
Anamitra
-----Original Message-----
From: Vdaygiri, Subu [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 25, 2000 12:34 PM
To: [EMAIL PROTECTED]
Subject: Primary Key - sequence from Oracle
In J2EE CMP (container - managed) bean, what changes I might need to make to
the bean or PK class in order to use a sequence from Oracle to generate the
primary key ?
Thanks a lot for the help !!
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".