MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology


EJB Projects

EJB Project 1

EJB Examples


Creating A Session Bean
Previous Home Next

Session beans have a very simple framework and it's similar to entity beans. In Session bean contain have a remote interface and a home interface, but no primary key.

They also do not need to be backed by a database or other form of permanent storage. Again, we will be using Blizzard to generate our basic framework.

Our session bean will be a stock-price quoting agent. It will live on a machine where current stock prices are available. The clients of the session bean will be able to specified a stock and obtain its current price.

It's create the session bean, and run the Blazix EJB wizard Blizzard, and select Create a Session bean. Fill in the bean name, package name and directory name. Select stateful and let the container manage transaction boundaries. Add data items stock(String) and price (float). We do not want a setter for price, but make sure to provide a setter for stock.

After that to build the framework examine the files created by the wizard. It's Look in the remote interface, the home interface and the bean class. Everything is similar to the entity beans, but there is no primary key and therefore no find ByPrimary key.


In the bean have implementation file, add an import for* and delete the member variable price. Also remove the price argument to the ejbCreate method and remove the statement where the price member variable is getting set.

public float gettingPrice() throws java.rmi.RemoteException, 
 BufferedReader br; 
     br = new BufferedReader( 
             new FileReader( "C:\\StockPrices.txt" )); 
	 String line; 
     String prefix = stock.toLowerCase() + ":"; 
     while (( line = reader.readLine()) != null ) { 
         if ( line.toLowerCase().startsWith( prefix )) { 
             line = line.substring( prefix.length()); 
             return Float.parseFloat( line.trim()); 
     throw new java.rmi.RemoteException( "Not found" ); 

     // In product-level coding we would define an exception 

     // class for this, but for this sample we 

     // will just put RemoteException to dual use! 
Previous Home Next