Hi Martin, Should be something like this. 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(); Hope this helps, Eric :-) Martin Stiel wrote: > Hello, > > 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)? > > Thanks in advance, > > Martin. > > ________________________________________ > > 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". ---- To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "unsubscribe jonas-users". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".