Hi Subu,

I should note that the solution provided by Jonathan Weedon on the Inprise
Application Server newsgroup does reduce the overhead associated with
calling the sequence number (making a sql call) each time you create a bean.

kind regards,

William Louth

> -----Original Message-----
> From: Bhattacharyya, Ana [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, April 25, 2000 5:52 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: Primary Key - sequence from Oracle
>
> 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".


***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************

===========================================================================
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".

Reply via email to