Yes you CAN do it in CMP entity beans.

Here's the solution that we chose to use.

Inside the ejbCreate() method, we added code to
*       get a Connection from DriverManager
*       from the Connection, get a PreparedStatement with the SQL to grab
the next sequence number from the db
   ("SELECT customer_seq.nextval FROM dual")
*       execute the prepared statement query
*       grab the sequence number out of the result set.
*       close the Connection


Actually instead of using DriverManager, we defined a DataSource object
that's stored in the JNDI namespace. It's a little bit more efficient.


Dan

> -----Original Message-----
> From: Sven van ´t Veer [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, January 26, 2001 6:19 AM
> To:   [EMAIL PROTECTED]
> Subject:      Re: Insert EJB into Autonumber's field in  Oracle database
>
> You can´t at leas not with CMP. You should let your bean create the key
> field.
>
> Gunawan Tanudy wrote:
>
> > HI..
> > Can somebody tell me how to insert records into  oracle database(the
> > field is autonumber)  through entity bean (the entity bean type is CMP)
> > Thanks alot.
> >
> >
> > Gun
> >
> >
> ==========================================================================
> =
> > 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".

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