Hi Eric,

thank you for your comments, but I have some other questions: 

> Context ctx = new InitialContext();
> DataSource ds = (DataSource)ctx.lookup("jdbc/MyDS"); // or java:comp/env/jdbc/MyDS
> // not really sure on this server
> Connection conn = ds.getConnection();
> ....
> conn.close();

        Where and how is the string "jdbc/MyDS" (in the DS lookup) defined. Do I have 
to 
declare it at the XML-Descriptor in the part of the CMP-Entity? If yes, what's the 
name 
of the tag for this field?

Thanks in advance,

Martin.








former mail:

> Martin Stiel wrote:
>
>         I try to get new database IDs via Oracle-sequences for an container managed
> persistence entity-bean, but I don't know how to get a database-connection in the
> ejbCreate-method of the bean:
>
> public BeanPK ejbCreate()       throws CreateException {
>         try {
>                 Connection conn = ?? 'getDBConnection' ??
>                 Statement stmt = conn.createStatement();
>                 ResultSet rs = stmt.executeQuery("SELECT Object_id.nextval FROM 
DUAL");
>                         if (rs.next()) id = rs.getInt(1);
>                         else throw new CreateException("Error.");
>                         stmt.close();
>                         conn.close();
>         } catch (SQLException e) {
>                  throw new CreateException("Error.");
>         }
>         return null;
> }
>
> Does anybody know, how I can get a database-connection in a simple way inside the
> implementation of a container managed persistence entity-bean? Or is there another
> possibility to create a new Primary Key (database ID)?




________________________________________

outermedia gbr - internet kommunikation
eva duvenkamp, nils bader
und simon oldeboershuis

post:
greifswalder str. 207
berlin 10405

phone: (+49-30) 44 35 09 40
< http://www.outermedia.de >

martin stiel
< mailto:[EMAIL PROTECTED] >
< http://www.informatik.hu-berlin.de/~stiel >
----
This list is cross-posted to two mail lists.  To unsubscribe,
follow the instructions below for the list you subscribed to.
For objectweb.org: send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe ejb-container-group".
For enhydra.org: send email to [EMAIL PROTECTED] and include
in the body of the message "unsubscribe ejb-container-group".

Reply via email to