The J2EE Platform,JDBC(Java Database Connectivity)
Total Page:16
File Type:pdf, Size:1020Kb
Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 1 The J2EE Platform,JDBC(Java Database Connectivity) Topics Covered 1. Introduction to J2EE 2. Enterprise Architecture Style. 3. Enterprise Architecture 4. J2EE Platform. 5. J2EE API’s. 6. Introduction to J2EE APIs 7. introduction to container 8. Tomcat as a web container 9. Introduction. 10. JDBC Architecture 11. Datatypes in JDBC 12. Processing Queries 13. Database exception handling 14. Database Driver 15. JDBC API for connectivity 16. Connection 17. Driver Manager class 18. Statement 19. Prepared Statement 20. Callable Statement 21. ResultSet 22. Other JDBC API 23. Database Meta Data 24. Result set Meta Data 25. Connecting with Databses(MySQL,Oracle,Access) Page 1 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 Introduction to J2EE Core java application only provides facility to work with windows based applications. If we required developing the enterprise level application, it will not work. Advance java programming provides the facility to develop the Enterprise based and Internet based Application. The J2EE is an open source. It reduces the cost of developing multi-tier applications. It provides a number of APIs to develop the different types of applications, such as JDBC(Java Database Connectivity) used for making connection between the java programs and database, JSP and servlets to create the dynamic web page, RMI(Remote Method Invocation) to create the remote objects. J2EE platforms also include concept of containers to provide the interface between the clients, server and the database. J2EE provides many framework such as JSF, spring, structs, hibernate to develop very attractive, secure, user-friendly, database driven enterprise application. 1. Introduction The Tier A tier is an abstract concept that defines a group of technologies that provides one or more services to its clients. In simplest words, tier is collection of similar technologies in a group. Introduction to Enterprise Application Design Framework Enterprise Application is divided in to following six (6) logical layers which are related to the client tier, middle tier, and database tier. It defines which layer belongs to which tier. Presentation Manager . It defines User interface . It is located on the client tier. Manages the information displayed to the user. Presentation Logic . Defines the Navigation system of the user interface . Focused on how and what will be displayed to the user. It may locate with the client tier or business tier or the database tier, based on thin client and thick client. Application Logic . Defines the actual application logic with it. It may be, connectivity with the database, validation over the various inputs etc. It may locate with the client tier or business tier or the database tier, based on thin client and thick client. Business Logic . Contains business rules of applications. Should be shared with whole application. Page 2 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 . It may located with business tier or the database tier, based on thin client and thick client. Database Logic . Defines the table structure and relation among the tables of database . Includes various constraints of the table. Located with the database tier. Database Manager . Stores the persistent (constant) data. Always located with the database tier. Enterprise Architecture Style Single tier Architecture When User inputs, its verifications, business logic, and data access all these are combined together in a single computer such kind of architecture is known as Single tier architecture. In this all layers are located on a single machne. Advantages . Easy to manage . Data consistency is simple due to data stored at single location. Disadvantages . Single storage is not sufficient due to large number of data . Sharing of data in large amount is not possible. Multiple user can’t be handled Two tier Architecture Two tier architecture is divided into two separate tiers, client machine and database server machine (server). The application includes the presentation and business logic. Data accessed by connecting client machine to a database which is lying on another machine (i.e. server) In this architecture there are various types of clients which are discussed below. Advantages . Any changes made in data access logic will not affect the presentation and the business logic . Using this type of architecture it is easy to develop an application. Page 3 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 Disadvantages . Only supports limited number of users. Because each client requires its own connections and each connection requires CPU and memory. So, when number of connection increases the database performance decreases. Thin Client . In two tier architecture, presentation manager resides only with the client tier then such client is called Thin client, while other presentation logic, application logic, business logic, data logic and database manager reside with the server side. Thick Client . In two tier architecture, presentation manager, presentation logic and application logic are resides in client tier then such architecture is called thick client. Other like business logic, data logic and database manager resides with the server side Page 4 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 Normal Client . In two tier architecture, if the presentation manager and presentation logic resides in the client tier then the client is called Normal Client. Other like application logic, business logic, data logic and database manager resides with the server side. Three tier Architecture Applications which are divided into three tiers client tier, middle tier (business tier) and database tier is known as three tier architecture application. Logic is physically divided into separate tier. The presentation layer and logic runs on the client machine. Application and business logic runs on J2EE server and database logic is there with database layer. Thin Client Page 5 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 . In three tier architecture if the presentation manager is resides only with the client tier then client is called as thin client. Presentation logic, application logic and business logic are with the business tier . Database logic and database manager are with the database tier (EIS – Enterprise Information System.) Thick Client . In three tier architecture if the presentation manager ,presentation logic, application logic resides with the client tier then client is called as thick client. Business logic only with the business tier . Database logic and database manager are with the database tier (EIS – Enterprise Information System.) Advantages . Improves scalability since application server are deployed on many machines. Database connection not required longer from each and every client, only requires connections from a smaller number of application server. Better reusability due to same logic can be initiated from many clients. Security is ensured because not direct access to the database. Disadvantages . Increases complexity N-tier architecture Application divided into more than three tier can be called as N-tier architecture. In N-tier architecture it is not decided how many tier can be present. Number of tiers in application is depends on the computing and network hardware on which application is to be deployed. Basically divided into client tier, web tier, business (EJB) tier and database tier (EIS). Client tier . Collection of user interface for user request and the print the response . Runs on the client machine. Uses browser or applet as client side application. Web tier . Collection of JSP and servlet dynamic webpages to handle the HTTP specific request logons, session , accesses the business services and response back to the client. Business tier . Collection of business logic for J2EE application. For example EJB (Enterprise JavaBeans) . Using such business tier, same business logic can support different types of client like browser, WAP, other stand-alone application. Database (EIS) tier . EIS tier consist of the DBMS/RDBMS. Page 6 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 . Handles User SQL requests and generates appropriate response based on the queries. Stores all persistent data in database Advantages . Separation of User interface logic, business logic is done . Business logic resides on small number of centralized machines. Easy to maintain, to manage, to scale, loosely coupled etc., Modification is easy Disadvantages . More complex structure . Difficult to setup and maintain all separated layers Enterprise Architecture Java 2 Enterprise edition is basically developed for commercial project and web- solution. Business solution for commercial project solved using multi-tier architecture. The J2EE platform use multi-tier distributed application model for enterprise application. By dividing application logic into various component according to its tasks or functions and various application components that are gathered J2EE application are installed on different machine depending on the tier. Page 7 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 Following tiers are available for J2EE. Client tier (Client machine) . Web tier (J2EE server) . Business tier ( J2EE server) . EIS tier (database server) J2EE Platform Introduction to editions of Java. J2SE – Java 2 standard edition normally used for developing desktop application.