Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
PROJECT REPORT
Submitted in partial fulfilment of the requirements for the Award of THE degree of
Project Guide Mrs.Deepti Gupta Gope Asst. Prof. (CE Deptt.) Prof. ( IT Deptt.)
CERTIFICATE
This is to certify that the project entitled Online Banking in J2EE and ORACLE undertaken by:Vinitesh&Jatin student of T.I.T&S (Bhiwani) in partial fulfilment of the requirements for the award of the degree of Bachelor of technology in Computer engineerig, embodies the work done by him under our supervision.
ACKNOWLEDGEMENT
I take this opportunity to express my sincere thanks and deep gratitude to all those people who extended their whole hearted co-operation and have helped us in completing this project. With deep sense of gratitude, we express our thanks to my project guide Mr.PROSANTA GOPE his able guidance and valuable suggestion that were very much required for the completion of this project. I express my humble gratitude to Mr.Prosanta Gope for providing us useful guidance and personally inspecting my work. He has been the key factor and motivating force in successful completion of this project. Under his guidance this project never posed a problem to us. We are also thankful to our teachers who supported us in making this project a real success. Our parents who encouraged us at each and every step.
The main objective of this project is to provide easy maintenance of the customer information and their accounts in the banks. It is also used to reduce the work load by reducing the bulk paper work and also by generating automated data based reports for the review of transactions in new or old accounts of respective customers. It reduces the tedious mental task to develop a record of all the information for the customer accounts. The Online Banking System is an important part of any Bank or any type of management. This project has been developed with the objective to develop Online Banking System for any bank with very little effort. It manages the record of all the customers, their personal details, annual income and records of new & old transactions.
CONTENTS
DESCRIPTION Introduction to the project Platform used Software development & life Cycle J2EE(Java 2 Enterprise Edition) JSP,Servlet & EJB Introduction Project Design Modules & their description E-R Diagram Future Scope of the project Conclusion Bibliography
PLATFORM USED
Hardware Required(i) 512 MB RAM. (ii) Pentium 4 or equivalent processor.
Software Required(i) JDK 1.5 or 1.6 (ii) Oracle (Database) (iii) Apache Tomcat web server (iv) Eclipse
Technology Used(i) J2EE (ii) SERVLET, JSP, JDBC, JND, RMI (iii) TOMCAT SERVER or J2EE SERVER
PlatformBackup Media-
Windows 7 or VISTA
Hard Disk.
This software is developed using Windows-XP as system software and is tested to be executed on all the operating systems given above.
Phases of the System Development Life Cycle :System Development Life Cycle (SDLC) is a well-defined process by which a system is conceived, developed and implemented. The system development life cycle consists of the following phases. 1. Preliminary survey or Investigation 2. Feasibility Study 3. System Analysis 4. Design of System 5. Development of Software 6. System Testing 7. Implementation and evaluation 8. Maintenance
So in my project system I have followed almost every step required to be followed while developing the system.
Preliminary Survey:-
One of the most difficult tasks of the system analyst is identifying the real problem of the existing system. Without clear understanding of the problem in the system, any further work done will lead to wastage of effort at a later stage. While doing preliminary survey for my project I found that the present system in used is a manual system. Which was not capable of fulfilling the entire requirement? At the same time manual system is responsible for wastage of time effort and money. So there is a need of computerized Bookshop information system. Feasibility Study: The next step is to examine the feasibility of the proposed system. This involves evaluating the costs and benefits of the system. While feasibility studies I found that my system is feasible in technical, economical and operational point of views.
Technical feasibility:
During this study, the analyst identifies the existing computer systems (hardware and software) of the concerned department and determines whether these technical resources are sufficient for the proposed system or not. I found my system is feasible in this point of view.
Economic Feasibility:
Economic feasibility is the most important study that determines the cost and benefits of the proposed system and compares with the budget. I found that my project is feasible in this point of view.
Operational Feasibility:
During operational feasibility study, it is determined whether the system will operate in the way that user wants or not. This test of feasibility asks if the system will work when it is developed and installed. I found that my project is also feasible in this point of view.
System Analysis:
When the systems analyst decides that the requested system is feasible and the management agrees to continue the development process the next phase of SDLC is determination of systems requirements. During the system analysis we use mainly two methods to collect that information and interview of the concern person. A part from that various tools of structure analysis like flow chart DFD are also used to make a clear understanding of the system.
Design of System:
In the system design phase, the primary objective is to identify user requirements and to build a system that satisfies these requirements, systems specialists often refer to this stage as logical design, in contrast to the process of developing program software, which is referred to as physical design. During design false of my project the first step was identification of data requirement (input requirement, storage devices, output devices etc.) In the next step I develop the database for my project in Microsoft access as back-end in the next step I moves to words form designing coding in Visual studio as front-end .In next step was connection of database with my form using ado connectivity.
Development of Software:
In this phase, the system is actually programmed. The analyst should decide whether to buy commercial software or to develop new customized programs with the help of programmers. Programmers are also responsible for documenting the program, providing an explanation of how and why certain procedure is coded in specific ways.
System Testing:
The main purpose of this phase is to find the errors and correct them. A successful test is one, which finds an error. When my system becomes ready to be implemented next step was system testing. Various type of testing procedure used by me in my project: 1. Unit testing 2.Module testing 3.Sub testing 4.System testing
Implementation consists of installing hardware, software, training of all the users and collecting data needed to use it. Therefore, this phase involves training of the users for using the system and also providing them friendly documentation to refer to. So my system ready to be almost to proposed system.
2. What is Java?
Java is a programming language for producing programs which are computer, or platform independent. This simply means that the same program will run on different computers without modification. For example, WordPerfect can currently be used on PCs or Macintoshes; however different versions of the same program are required for each computer type.
Java was also the first programming language to be used to provide executable content on the WWW. In this context executable content generally refers to programs. Small programs known as applets can be written in the Java language. These applets can be loaded as part of a web page to give the page some intelligence (providing the browser supports applets). For example, an applet could be loaded as part of a WWW order form to perform calculations and display a running cost as the purchaser adds items to or removes items from the order form. This simple example demonstrates how Java is bringing new levels of interactivity to the WWW
Servlet
Java Servlets/JSP are part of the Suns J2EE Enterprise Architecture that is the web development part. Java Servlet is a simple, consistent mechanism for extending the functionality of a web server. They are precompiled Java programs that are executed on the server side and require a Servlet container to run in the program and the latest Servlet Specification is 2.3. We use Servlets because they work well in a Heterogeneous Environments.They are OS and platform independent.Also they work with all major web servers (Sun App,Apache Tomcat,Jboss,etc).They have well defined Web Architecture framework and standard built in services such as: Standard Approach to Authentication Database connection pooling Complete support for sessions via cookies and/or URL re-writing A servlet has clean separation of Controller/Logic from Presentation It is more efficient than others.There are free Servlet/JSP containers and connectors that run under both UNIX and win32.
Web Deployment Descriptor: /web-inf/web.xml Part of the standard Defines servlets used in the web application Maps servlets to URLs A servlet can map to many URLs Defines resources available to the web app Defines security constraints Defines other stuff like Welcome file list Session timeout Error page mapping
It is a simplified, fast way to create dynamic web content. It is mainly HTML or XML pages with embedded Java Code.Java Beans can be a mix of template data in HTML/XML with some dynamic content. A JSP page is first converted into a Java Servlet automatically by the Servlet container, and then it is cached or executed. Latest JSP Specification is 1.2.
JSP Constructs 1: Used in JSP pages, pages that end *.jsp Comment <%-- Comment --%> Declaration <%! int x = 0; %> Expression <%= expression %> Outputs to the Response stream Like a printf to the browser Do NOT use semi-colon to terminate the line Scriplets - contains Java Code <% code fragments %>
JSP Constructs 2:<% if (value.getName().length != 0) { %> <H2>The value is: <%= value.getName() %></H2> <% } else { %> <H2>Value is empty</H2> <% } %>
1.request-Browsers Request Object(use to get HTTP headers,length etc)
2.response-HttpResponse Object
session internal HttpSession Object pageContext application out, same as <%= %> config servlet configuration page exception JSP Directives Are messages or instructions to the JSP container
JSP Constructs 4: Do not produce any output page directive <%@ page import=com.lucek.* %> Commonly used for importing class paths include directive <%@ include file=header.htm %> Good for including static content taglib lists the tag library descriptor location Required when using tab libraries
JSP Actions: JSP actions are special tags that affect the output stream and are normally used with Java beans Most commonly used: <jsp:useBean>,<jsp:getProperty>,<jsp:setProperty> The code below will display the lastName property of the student bean on the output stream <jsp:useBean id="student" scope="request" class="com.lucek.dto. StudentValue" /> <jsp:getProperty name="student" property="lastName" />
Servlet Container/Engine:
Servlets/JSP requires a Container Apache Tomcat is the reference implementation of the Servlet/JSP Specs It is open source, small, install quickly,and is FREE Latest Version is 4.1.24 Web Site: jakarta.apache.org/tomcat It includes a simple HTTP 1.1 server, good enough for development and small intranets.
Tomcat Install: Requires a JDK, get 1.4.1 and install into c:\jdk or $HOME/jdk Add JAVA_HOME to your environment and the bin directory to your PATH Good practice to unpack into c:\tomcat or $HOME/tomcat Add CATALINA_HOME to your environment and the bin directory to your PATH
Everything is relative to $CATALINA_HOME /bin Startup/shutdown scripts /conf Server.xml main configuration file /common common class and jar files used by Tomcat and web applications Put JDBC drivers here /server class and jar files used by Tomcat internally /shared class and jar files for all web applications /webapps This is where you put your web application in a subdirectory or external context file.
Starting Tomcat:
/bin/startup.bat or startup.sh
Point Browsers to http://localhost:8080, should see default page All the Docs are there on the default page! Check out the examples pages, good tutorials
Other Development Tools: Java IDE NetBeans Tomcat is built in, but is an older version Includes full Servlet and JSP debugging Junit Standard Automated Unit Testing Tool Jedit Programmers Editor Written in Java
J2EE Components
J2EE applications are made up of components. A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and that communicates with other components. The J2EE specification defines the following J2EE components: Application clients and applets are components that run on the client. Java Servlet and JavaServer Pages (JSP) technology components are Web components that run on the server. Enterprise JavaBeans (EJB) components (enterprise beans) are business components that run on the server. J2EE components are written in the Java programming language and are compiled in the same way as any program in the language. The difference between J2EE components and standard Java classes is that J2EE components are assembled into a J2EE application, verified to be well formed and in compliance with the J2EE specification, and deployed to production, where they are run and managed by the J2EE server.
J2EE Clients
A J2EE client can be a Web client or an application client.
Web Clients
A Web client consists of two parts: dynamic Web pages containing various types of markup language (HTML, XML, and so on), which are generated by Web components running in the Web tier, and a Web browser, which renders the pages received from the server. A Web client is sometimes called a thin client. Thin clients usually do not do things like query databases, execute complex business rules, or connect to legacy applications. When you use a thin client, heavyweight operations like these are off-loaded to enterprise beans executing on the J2EE server where they can leverage the security, speed, services, and reliability of J2EE server-side technologies.
Applets
A Web page received from the Web tier can include an embedded applet. An applet is a small client application written in the Java programming language that executes in the Java virtual machine installed in the Web browser. However, client systems will likely need the Java Plug-in and possibly a security policy file in order for the applet to successfully execute in the Web browser. Web components are the preferred API for creating a Web client program because no plug-ins or security policy files are needed on the client systems. Also, Web components enable cleaner and more modular application design because they provide a way to separate applications programming from Web page design. Personnel involved in Web page design thus do not need to understand Java programming language syntax to do their jobs.
Web Components
J2EE Web components can be either servlets or JSP pages. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content. Static HTML pages and applets are bundled with Web components during application assembly, but are not considered Web components by the J2EE specification. Server-side utility classes can also be bundled with Web components and, like HTML pages, are not considered Web components. Like the client tier and as shown in Figure 13, the Web tier might include a JavaBeans component to manage the user input and send that input to enterprise beans running in the business tier for processing.
Business Components
Business code, which is logic that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier. Figure 1.4 shows how an enterprise bean receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client program.
Figure 1.4 Business and EIS Tiers There are three kinds of enterprise beans: session beans, entity beans, and message-driven beans. A session bean represents a transient conversation with a client.When the client finishes executing, the session bean and its data are gone. In contrast, an entity bean represents persistent data stored in one row of a database table. If the client terminates or if the server shuts down, the underlying services ensure that the entity bean data is saved.A message-driven bean combines features of a session bean and a Java Message Service (JMS) message listener, allowing a business component to receive JMS messages asynchronously. This tutorial describes entity beans and session beans.
J2EE Containers
Normally, thin-client multitiered applications are hard to write because they involve many lines of intricate code to handle transaction and state management, multithreading, resource pooling, and other complex lowlevel details. The componentbased and platform-independent J2EE architecture makes J2EE applications easy to write because business logic is organized into reusable components. In addition, the J2EE server provides underlying services in the form of a container for every component type. Because you do not have to develop these services yourself, you are free to concentrate on solving the business problem at hand.
Container Types
The deployment process installs J2EE application components in the J2EE containers illustrated in Figure 1.5.
J2EE server
The runtime portion of a J2EE product. A J2EE server provides EJB and Web containers.
Web container
Manages the execution of JSP page and servlet components for J2EE applications. Web components and their container run on the J2EE server.
Applet container
Manages the execution of applets. Consists of a Web browser and Java Plug-in running on the client together.
An application client developer performs the following tasks to deliver a JAR file containing the J2EE application client: Writes and compiles the source code Specifies the deployment descriptor for the client Bundles the .class files and deployment descriptor into the JAR file
Application Assembler
The application assembler is the company or person who receives application component JAR files from component providers and assembles them into a J2EE application EAR file. The assembler or deployer can edit the deployment descriptor directly or use tools that correctly add XML tags according to interactive selections. A software developer performs the following tasks to deliver an EAR file containing the J2EE application: Assembles EJB JAR and WAR files created in the previous phases into a J2EE application (EAR) file Specifies the deployment descriptor for the J2EE application Verifies that the contents of the EAR file are well formed and comply with the J2EE specification
Database Access
The relational database provides persistent storage for application data. A J2EE implementation is not required to support a particular type of database, which means that the database supported by different J2EE products can vary. See the Release Notes included with the J2EE SDK download for a list of the databases currently supported by the reference implementation.
J2EE APIs
The Java 2 Platform, Standard Edition (J2SE) SDK is required to run the J2EE SDK and provides core APIs for writing J2EE components, core development tools, and the Java virtual machine. The J2EE SDK provides the following APIs to be used in J2EE applications.
Tools
The J2EE reference implementation provides an application deployment tool and an array of scripts for assembling, verifying, and deploying J2EE applications and managing your development and production environments. See Appendix B for a discussion of the tools.
Scripts
Table 11 lists the scripts included with the J2EE reference implementation that let you perform operations from the command line.
The enterprise bean in our example is a stateless session bean called ConverterEJB. The source code for ConverterEJB is in the j2eetutorial/examples/src/ejb/converter directory.
import javax.ejb.EJBHome; public interface ConverterHome extends EJBHome { Converter create() throws RemoteException, CreateException; }
Now you are ready to compile the remote interface (Converter.java), home interface (ConverterHome.java), and the enterprise bean class (Converter-Bean.java). 1. In a terminal window, go to the j2eetutorial/examples directory. 2. Type the following command: ant converter This command compiles the source files for the enterprise bean and the J2EE application client. It places the resulting class files in the j2eetutorial/examples/build/ejb/converter directory (not the src directory).
The ConverterHome interface defines life-cycle methods such as create. Before the ConverterClient can invoke the create method, it must locate and instantiate an object whose type is ConverterHome. This is a four-step process. 1. Create an initial naming context. Context initial = new InitialContext(); The Context interface is part of the Java Naming and Directory Interface (JNDI). A naming context is a set of name-to-object bindings. A name that is bound within a context is the JNDI name of the object. An InitialContext object, which implements the Context interface, provides the starting point for the resolution of names. All naming operations are relative to a context. 2. Obtain the environment naming context of the application client. Context myEnv = (Context)initial.lookup("java:comp/env");The java: comp/env name is bound to the environment naming context of the ConverterClient component. 3. Retrieve the object bound to the name ejb/SimpleConverter. Object objref = myEnv.lookup("ejb/SimpleConverter");The ejb/ SimpleConverter name is bound to an enterprise bean reference, a logical name for the home of an enterprise bean. In this case, the ejb/ SimpleConverter name refers to the ConverterHome object. The names of enterprise beans should reside in the java:com/env/ejb subcontext. 4. Narrow the reference to a ConverterHome object. ConverterHome home =(ConverterHome) PortableRemoteObject.narrow(objref,ConverterHome.class);
To create the bean instance, the client invokes the create method on the ConverterHome object. The create method returns an object whose type is Converter. The remote Converter interface defines the business methods of the bean that the client may call. When the client invokes the create method, the EJB container instantiates the bean and then invokes the ConverterBean.ejb-Create method. The client invokes the create method as follows: Converter currencyConverter = home.create();
<%@ page import="Converter,ConverterHome,javax.ejb.*, javax.naming.*, javax.rmi.PortableRemoteObject, java.rmi.RemoteException" %> <%!private Converter converter = null; public void jspInit() { try { InitialContext ic = new InitialContext(); Object objRef = ic.lookup("java:comp/env/ejb/TheConverter"); ConverterHome home = (ConverterHome)PortableRemote Object.narrow(objRef, ConverterHome.class); converter = home.create(); } catch (RemoteException ex) { ... } } ... %> <html> <head> <title>Converter</title> </head> <body bgcolor="white"> <h1><center>Converter</center></h1> <hr> <p>Enter an amount to convert :</p> <form method="get"> <input type="text" name="amount" size="25"> <br> <p> <input type="submit" value="Submit"> <input type="reset" value="Reset"> </form> <%String amount = request.getParameter("amount"); if ( amount != null && amount.length() > 0 ) { BigDecimal d = new BigDecimal (amount); %>
<p><%= amount %> dollars are <%= converter.dollarToYen(d) %> Yen. <p><%= amount %> Yen are <%= converter.yenToEuro(d) %> Euro. <% } %> </body> </html>
10. Click Next. 11. In the Review dialog box, click Finish. 12. In the Deployment Progress dialog box, click OK when the deployment completes.
discountPercent variable. The applyDiscount method, which follows, is in the CheckerBean class. public double applyDiscount(double amount) { try { double discount; Context initial = new InitialContext(); Context environment =(Context)initial.lookup("java:comp/env"); Double discountLevel =(Double)environment.lookup("Discount Level"); Double discountPercent =(Double)environment.lookup("Discount Percent"); if (amount >= discountLevel.doubleValue()) { discount = discountPercent.doubleValue(); } else { discount = 0.00; } return amount * (1.00 - discount); } catch (NamingException ex) { throw new EJBException("NamingException: "+ex.getMessage()); } }
In addition, an entity bean class with bean-managed persistence has these requirements: The class is defined as public. The class cannot be defined as abstract or final. It contains an empty constructor. It does not implement the finalize method.
insertRow(id, firstName, lastName, balance); } catch (Exception ex) { throw new EJBException("ejbCreate: " +ex.getMessage()); } this.id = id; this.firstName = firstName; this.lastName = lastName; this.balance = balance; return id; } Although the SavingsAccountBean class has just one ejbCreate method, an enterprise bean may contain multiple ejbCreate methods. For an example, see the CartEJB.java source code in the j2eetutorial/examples/src/ejb/cart directory. When writing an ejbCreate method for an entity bean, be sure to follow these rules: The access control modifier must be public. The return type must be the primary key. The arguments must be legal types for the Java RMI API. The method modifier cannot be final or static. The throws clause may include the javax.ejb.CreateException and exceptions that are specific to your application. An ejbCreate method usually throws a CreateException if an input parameter is invalid. If an ejbCreate method cannot create an entity because another entity with the same primary key already exists, it should throw a javax.ejb. DuplicateKeyException (a subclass of CreateException). If a client receives a CreateException or a DuplicateKeyException, it should assume that the entity was not created. The state of an entity bean may be directly inserted into the database by an application that is unknown to the J2EE server. For example, a SQL script might insert a row into the savingsaccount table. Although the entity bean for this row was not created by an ejbCreate method, the bean can be located by a client program.
should throw a javax.ejb.RemoveException. For a comparison of system and application exceptions, see the section Handling Exceptions. An entity bean may also be removed directly by a database deletion. For example, if a SQL script deletes a row that contains an entity bean state, then that entity bean is removed.
public void ejbLoad() { try { loadRow(); } catch (Exception ex) { throw new EJBException("ejbLoad: " +ex.getMessage()); } } public void ejbStore() { try { storeRow(); } catch (Exception ex) { throw new EJBException("ejbStore: " +ex.getMessage()); } }
throw new EJBException("ejbFindByLastName " +ex.getMessage()); } return result; } The finder methods that are specific to your application, such as ejbFindBy- LastName and ejbFindInRange, are optionalbut the ejbFindByPrimaryKey method is required. As its name implies, the ejbFindByPrimaryKey method accepts as an argument the primary key, which it uses to locate an entity bean. In the SavingsAccount Bean class, the primary key is the id variable. Here is the code for the ejbFindByPrimaryKey method: public String ejbFindByPrimaryKey(String primaryKey) throws FinderException { boolean result; try { result = selectByPrimaryKey(primaryKey); } catch (Exception ex) { throw new EJBException("ejbFindByPrimaryKey: " + ex.getMessage()); } if (result) { return primaryKey; } else { throw new ObjectNotFoundException ("Row for id " + primaryKey + " not found."); } } The ejbFindByPrimaryKey method may look strange to you, because it uses a primary key for both the method argument and return value. However, remember that the client does not call ejbFindByPrimary Key directly. It is the EJB container that calls the ejbFindByPrimary Key method. The client invokes the findByPrimaryKey method, which is defined in the home interface. The following list summarizes the rules for the finder methods that you implement in an entity bean class with bean-managed persistence:
The ejbFindByPrimaryKey method must be implemented. A finder method name must start with the prefix ejbFind. The access control modifier must be public. The method modifier cannot be final or static. The arguments and return type must be legal types for the Java RMI API.(This requirement applies only to methods defined in a remote not localhome interface.) The return type must be the primary key or a collection of primary keys. The throws clause may include the javax.ejb.FinderException and exceptions that are specific to your application. If a finder method returns a single primary key and the requested entity does not exist, the method should throw the javax.ejb.ObjectNotFoundException (a subclass of FinderException). If a finder method returns a collection of primary keys and it does not find any objects, it should return an empty collection.
public String getLastName() { return lastName; } public BigDecimal getBalance() { return balance; } The SavingsAccountClient program invokes the business methods as follows: BigDecimal zeroAmount = new BigDecimal("0.00"); SavingsAccount duke = home.create("123", "Duke", "Earl",Zero Amount); ... duke.credit(new BigDecimal("88.50")); duke.debit(new BigDecimal("20.25")); BigDecimal balance = duke.getBalance(); The requirements for the signature of a business method are the same for both session and entity beans: The method name must not conflict with a method name defined by the EJB architecture. For example, you cannot call a business method ejb-Create or ejbActivate. The access control modifier must be public. The method modifier cannot be final or static. The arguments and return types must be legal types for the Java RMI API. This requirement applies only to methods defined in a remotenot localhome interface.The throws clause may include the exceptions that you define for your application.The debit method, for example, throws the Insufficient Balance Exception. To indicate a system-level problem, a business method should throw the javax.ejb.EJBException.
applies to a single entity bean, an instance with a unique identity. During a home method invocation, the instance has neither a unique identity nor a state that represents a business object. Consequently, a home method must not access the beans persistence state (instance variables). (For container-managed persistence, a home method also must not access relationships.) Typically, a home method locates a collection of bean instances and invokes business methods as it iterates through the collection. This approach is taken by the ejbHomeChargeForLowBalance method of the SavingsAccountBean class. The ejbHomeChargeForLowBalance method applies a service charge to all savings accounts with balances less than a specified amount. The method locates these accounts by invoking the findInRange method. As it iterates through the collection of SavingsAccount instances, the ejbHomeChargeForLowBalance method checks the balance and invokes the debit business method. Here is the source code of the ejbHomeChargeForLowBalance method: public void ejbHomeChargeForLowBalance( BigDecimal minimumBalance, BigDecimal charge) throws InsufficientBalanceException { try { SavingsAccountHome home = (SavingsAccountHome)context.get EJBHome(); Collection c = home.findInRange(new BigDecimal("0.00"), minimumBalance.subtract(new BigDecimal("0.01"))); Iterator i = c.iterator(); while (i.hasNext()) { SavingsAccount account = (SavingsAccount)i.next(); if (account.getBalance().compareTo(charge) == 1) { account.debit(charge); } } } catch (Exception ex) { throw new EJBException("ejbHomeChargeForLowBalance: " + ex.getMessage()); } }
The home interface defines a corresponding method named chargeForLowBalance. Since the interface provides the client view, the SavingsAccountClient program invokes the home method as follows: SavingsAccountHome home; ... home.chargeForLowBalance(new BigDecimal("10.00"), new BigDecimal("1.00"));In the entity bean class, the implementation of a home method must adhere to these rules: A home method name must start with the prefix ejbHome. The access control modifier must be public. The method modifier cannot be static. The throws clause may include exceptions that are specific to your application; it must not throw the java.rmi.RemoteException.
Home Interface
The home interface defines the methods that allow a client to create and find an entity bean. The SavingsAccountHome interface follows: import java.util.Collection; import java.math.BigDecimal; import java.rmi.RemoteException; import javax.ejb.*; public interface SavingsAccountHome extends EJBHome { public SavingsAccount create(String id, String firstName, String lastName, BigDecimal balance) throws RemoteException, CreateException; public SavingsAccount findByPrimaryKey(String id) throws FinderException, RemoteException; public Collection findByLastName(String lastName)
Remote Interface
The remote interface extends javax.ejb.EJBObject and defines the business methods that a remote client may invoke. Here is the SavingsAccount remote interface: import javax.ejb.EJBObject; import java.rmi.RemoteException; import java.math.BigDecimal; public interface SavingsAccount extends EJBObject { public void debit(BigDecimal amount) throws InsufficientBalanceException, RemoteException; public void credit(BigDecimal amount) throws RemoteException; public String getFirstName() throws RemoteException; public String getLastName() throws RemoteException; public BigDecimal getBalance() throws RemoteException; }
Handling Exceptions
The exceptions thrown by enterprise beans fall into two categories: system and application. A system exception indicates a problem with the services that support an application. Examples of these problems include the following: a database connection cannot be obtained; a SQL insert fails because the database is full, or a lookup method cannot find the desired object. If your enterprise bean encounters a system- level problem, it should throw a javax.ejb.EJBException. The container will wrap the EJBException in a RemoteException, which it passes back to the client. Because the EJBException is a subclass of the RuntimeException, you do not have to specify it in the throws clause of the method declaration. If a system exception is thrown, the EJB container might destroy the bean instance. Therefore, a system exception cannot be handled by the beans client program; it requires intervention by a system administrator. An application exception signals an error in the business logic of an enterprise bean. There are two types of application exceptions: customized and predefined. A
customized exception is one that youve coded yourself, such as the InsufficentBalanceException thrown by the debit business method of the SavingsAccountEJB example. The javax.ejb package includes several predefined exceptions that are designed to handle common problems. For example, an ejb-Create method should throw a CreateException to indicate an invalid input parameter. When an enterprise bean throws an application exception, the container does not wrap it in another exception. The client should be able to handle any application exception it receives. If a system exception occurs within a transaction, the EJB container rolls back the transaction. However, if an application exception is thrown within a transaction, the container does not roll back the transaction.
Any select methods, defining them as abstract The home methods The business methods The entity bean class must not implement these methods: The finder methods The finalize method
Since message-driven beans are based on the Java Message Service (JMS) technology, to understand the example in this chapter you should already be familiar with basic JMS concepts such as queues and messages. This chapter describes the source code of a simple message-driven bean example. Before proceeding, you should read the basic conceptual information in the section What Is a Message-Driven Bean?
msg = (TextMessage) inMessage; System.out.println ("MESSAGE BEAN: Message received: "+ msg.getText()); } else { System.out.println ("Message of wrong type: "+ inMessage.getClass().getName()); } } catch (JMSException e) { e.printStackTrace(); mdc.setRollbackOnly(); } catch (Throwable te) { te.printStackTrace(); } }
Project design
Basic
Flow of System
Gives log deta in ils Gives log details in
EMPLOYEE
Get custom details er S rches the DB ea Delete & m odify Accounts
CUSTOMER
ONLINE BANKING
Employee login:
It includes logins for those employees who work there inside the bank. It is only for NFB(National Film Board) employees. This page is made in JSP.
Home Page:
This page is displayed when a new customer first logins into his/her account. It contains links for other operations such as transaction, searching etc.
Sign-Up Form:
This page is used for giving registration details by the new customer to the site who has opened his account recently in the respective bank. In this a customer has to give his/her personal details like full name, annual income, phone number and also have to submit them for future use.
Transaction Form:
This page helps us to store the current and previous transactions done in his/her account and the medium of transaction.
View statement:
This form is used by the bank employees for searching the account details of the customers in their databases. The searching for account details can be done in two ways: By account id
Administrator Page:
This page is used for deleting all the information of a respective customer who has closed his account from the bank by using his/her account-id.
Update Page:
This page is used for updating or modifying any information regarding personal or account details of a customer by using his/her registration-id.
E-R Diagram
DATA TYPE NOTNU LL
USER_NA ME
PASSWO RD
PRIMA RY
COL_NA ME
SIZ E
USER
US ES
SEL_COL_G EN
TABLES
The table SEL_COL_GEN contains the following information: Sr.No Name of the variable
1. 2. 3. 4. 5. DATA TYPE NOTNULL PRIMARY SIZE COL_NAME
Constraint
Information
Stores the type of data selected by the user. If NOTNULL is checked by the user or not. If primary is checked by the user or not. Size provided by the user. Name of the column
The table USER stores the following information:Sr.No Name of the variable Constraint Information 1. USER_NAME Users name 2. PASSWORD Password to his account.
Better retrieval of records. Customer Record Maintenance. Multiple criteria based reporting. Transaction Entry Balance update and retrieval. Unit Master Entry and Item Master entry. Taking security into consideration, the customer account had to be password protected. I had two options, an encrypted password hidden in the registry or a file stored on disk (most secure but slower) or using a password hidden in the tag property in a control (less secure but faster and easier to code).I chose the latter as the former would be unnecessary, bulky in coding and it would take far too long to develop an effective algorithm for ciphering and deciphering.
CONCLUSION
The conclusion of this report is that after reading you will be able to make and run web application programs in Java and create other real world applications by paying much more attention to Java programming. One can also understand and
familiar with various J2EE technology which includes Servlets, JSP, EJB (Enterprise Java Beans) etc. Java can be used as the front-end for preparing any project. These java applications are needed to employ full functionality of the project. The reporting is done through various parameters passed from the form. In this application there is transaction entry and customer record system. This application is useful for person who needs money transaction in day to day working. Now he will find it easier because this is a combine application with all required utilities. Error handling has been done in this project.
Bibliography
NIIT Study material Sun Microsystems-Student Guide The Complete Reference(J2EE)