In EJB 3.0, determination mechanism is used to access the database in which the container manages the database linked operations. Developers can access database using JDBC API call openly in EJB business methods.
To display database access in EJB, we need to perform the following responsibilities −
Create a table books in default database postures.
After construction the EJB section, we need a client to access the stateless bean, which we will be going to create in the next section.
Let us construct a test EJB application to test EJB database access mechanism.
|1||Create a project with a nameEjbComponentunder a packagecom.Wisdomjobs.entityas explained in theEJB - Create Applicationchapter. You can also use the project created inEJB - Create Applicationchapter as such for this chapter to understand EJB data access concepts.|
|2||CreateBook.javaunder packagecom.Wisdomjobs.entityand modify it as shown below.|
|3||CreateLibraryPersistentBean.javaandLibraryPersistentBeanRemoteas explained in theEJB - Create Applicationchapter and modify them as shown below.|
|4||Clean and Build the application to make sure business logic is working as per the requirements.|
|5||Finally, deploy the application in the form of jar file on JBoss Application Server. JBoss Application server will get started automatically if it is not started yet.|
|6||Now create the EJB client, a console based application in the same way as explained in theEJB - Create Applicationchapter under topicCreate Client to access EJB. Modify it as shown below.|
EJBTester performs the following tasks −
Locate EJBTester.java in development explorer. Right click on EJBTester class and decide on run file.
Confirm the following output in Net beans console.
EJB(Enterprise JavaBeans) Related Interview Questions
|J2EE Interview Questions||Core Java Interview Questions|
|JDBC Interview Questions||JSP Interview Questions|
|Android Interview Questions||JMS(Java Message Service) Interview Questions|
|JavaServer Faces (JSF) Interview Questions||Java collections framework Interview Questions|
|Java 8 Interview Questions||Java Collections Interview Questions|
|Java Exception Handling Interview Questions||Java Concurrency Interview Questions|
|Java Serialization Interview Questions||Java Programmer Interview Questions|
|Java Inheritance Interview Questions||Java IO Interview Questions|
|Object Oriented Programming in PHP Interview Questions|
Ejb(enterprise Javabeans) Tutorial
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.