Yes and no. Yes..if you were to use entity beans that are automatically handled for you by the application server. No, if you want to use a session bean (ejb) to do the logic, but still have control over the entities in the database. CMP (Container Managed Persistence) is where you use the container to automatically find data, create tables, etc..it is in general supposed to be "much easier", however, because EJB 1.1 CMP is limited in areas such as table joins and advanced queries, it doesn't quite work out for more complicated database use. However, for simple stuff, like a table of login name/passwords and user-ids, you can easily use entity beans in EJB 1.1, as the table is most likely not going to be joined by others during a query. There are tools that are for EJB 1.1 that do this mapping for you, but they are not cheap, 3rd party (thus relying on 3rd party to get the job done, etc). BMP is where you write the jdbc code in an entity bean class, and your session bean class can use the entity bean class. This is much like how it is without EJB, only your design should focus on using ejb sessions (Stateless preferrably) for the logic, and entity EJB classes to model the actual data in the database, with the exception that each entity class has methods for searching, updating, inserting, removing, etc..to handle how it will be removed from the table. You may want to wait for EJB 2.0..if you can, which will offer alot more flexibility in joins and stuff like that..however most people are saying it is quite more complex than CMP with EJB 1.1, and that even BMP may be easier now. BMP gives you the most flexibility..as you write the code, but it is more involved and time consuming. CMP is easiest because you implement a few interfaces and the application server creates the implemented classes for you to manage the tables. > -----Original Message----- > From: Anthony Mak [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 08, 2001 6:43 PM > To: [EMAIL PROTECTED] > Subject: EJB > > > Dear all, > > I am creating a system using JSP/Servlet/EJB technologies. > The JSP is to > serve as the View, Servlet is the Controller and EJB is the > Model to access > an Oracle 7.3 database. > > I am new to EJB and I don't know what is the difference > between the code of > a normal JDBC program and a JDBC program that is used to access the > database. > > This is my code for access an Oracle database, would the code > look much > different if it is written for EJB architecture?? > > try { > conn = > DriverManager.getConnection("jdbc:oracle:thin:@"+host+":"+port > +":"+sid, > username,password); > > Statement stmt = conn.createStatement(); > ResultSet result = stmt.executeQuery("SELECT * FROM > ITEMS WHERE GROUP_ID = > "+group_id_str+" ORDER BY PRICE DESC"); > while (result.next()) { > item_name = result.getString("NAME"); > price = result.getFloat("PRICE"); > System.out.println(item_name+" > "+String.valueOf(price)); > } > > } catch (SQLException se) { > System.out.println("Cannot connect to database"); > } > > Anthony Mak > > ============================================================== > ============= > To unsubscribe: mailto [EMAIL PROTECTED] with body: > "signoff JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set > JSP-INTEREST DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets > =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to