Elements of Advanced JAVA Programming : Part-1

Introduction to the Two- Tier and the Three-Tier Architectures:

  • Client-server computing involves two or more computers sharing tasks related to a complete application. Ideally,, each computer is performing logic appropriate to its design and stated function.
  • The most widely used form of client-server implementation is a two-tier client-server. This involves a front-end client application communicating with a back-end database engine running on a separate computer.
  • Client program sends Structured Query Language (SQL) statements to the database servers. The server returns the appropriate results, and the client is responsible for handling the data.
  • The basic two-tier client-server model is used for applications that can run with many popular databases including ORACLE, Sybase, and Informix.
  • A major performance penalty is paid in two-tier client-server. The client software ends up with larger and more complex because most of the logic is handled there.
  • The use of server-side logic is limited to database operations. The client here is referred to as a thick client.
  • Thick clients tend to produce frequent network traffic for remote database access. This works well for intranet and local area network (LAN)-based network topologies but produces a large footprint on the desktop in terms of disk and memory requirements.
  • Also, not all back-end database servers are the same in the terms of server logic offered, and all of them have their own API sets that programmers must use to optimize and scale performance.
  • Three-tier client-server, which is described next, takes care of scalability, performance, and logic partitioning in a more efficient manner.

Three-tier Architecture:

  • Three-tier architecture is the most advanced type of client-server software architecture. A three-tier client-server demands a much steeper development curve initially, especially when you have to support a number of different platforms and network environments.
  • The payback comes in the form of reduced network traffic, excellent Internet and Intranet performance, and more control over system expansion and growth.

Three-Tier Client-Server Definition: Presentation—A Business logic/Functionality—A Data

  • The structure above shows a generic three-tier architecture.
  • The three components or tiers of the three tier client-server environment are presentation, business logic or functionality, and data.
  • They are separated such that the software for any one  of the tiers can be replaced by a different implementation without affecting the other tiers.
  • For example, you wanted to replace a character oriented screen (on screens) with GUI (the presentation tier), you would write the GUI using an established API or interface to access the same functionality programs in the character oriented screen.
  • The business logic offers functionality in terms of defining all of the business rules through which the data can be manipulated.
  • Changes to business policies can affect this layer without having any impact on the actual databases.
  • The third tier or data tier, includes existing systems, applications, and data that has been encapsulated to take advantage of this architecture with minimal transitional programming effort.

A Database Front End:

  • The JAVA programming language offers wide benefits to software engineers creating front end application for database oriented systems.
  • With its “Write Once Run Anywhere” language feature, the JAVA programming language offers immediate advantages in terms of its deployment on a wide range of hardware and operating systems.
  • Programmers do not have to write platform specific code for front end applications, even in a multiple platform environment.
  • With JAVA technology’s rich set of supported front development classes, you can interact with databases through the JDBC API.
  • The JDBC API provides a connectivity to back end databases that can be queried with results being handled by the front end.
  • In a two tier model, the database resides on a database server. The client executes a front application that opens a socket for communication over the network.
  • The socket provides a communication path between the client application and the back end server.
  • In the following illustration, client program sends SQL database query requests to the database server. The server returns the results to the client, which formats the results for presentation.
  • The figure given below shows an architecture:

Elements of Advanced JAVA Programming

  • Frequently used mechanism for data manipulations are often embedded as stored procedure.
  • Triggers automatically execute stored procedures when certain conditions are activated during the course of manipulations on the database.
  • The primary drawback of this model is that all business rules are implemented in the client application, creating large client-side runtimes and increased rewriting of the client’s code.
  • In a three tier model, the presentation and control logic is embedded in the client (front end)tier.It communicates with an intermediate server that provides a layer of abstraction from the back end applications.
  • This middle tier manages the business rules that manipulate the data per the governing conditions of the applications.
  • It can also accept connections from several clients to one or more database servers on a variety of communications protocols.
  • The middle tier provides a database independent interface for application for applications and makes the front end robust.
  • The figure given below shows an architecture:

Elements of Advanced JAVA Programming Introduction to the JDBC API:

  • An ability to create robust, platform independent applications and web based applets prompted developers to create front end connectivity solutions.
  • JavaSoft technology worked with database and database tool vendors to create a database management system independent (DBMS independent) mechanism that would enable developers to write client side applications that worked with all databases.
  • This effort resulted in the Java Database Connectivity Application Programming Interface (JDBC API).

JDBC, An Overview:

  • The JDBC provides a standard interface for accessing a relational database. Modeled after the open database connectivity (ODBC) specification, the JDBC package contains a set of classes and methods for issuing SQL statements, table updates, and calls to stored procedures.
  • The figure given below shows a Java programming language front end application uses the JDBC API to interact with the JDBC Driver Manager.
  • The JDBC Driver Manager uses the JDBC Driver API to load the appropriate JDBC driver. JDBC drivers, which are available from different database vendors, communicate with underlying DBMS.

Elements of Advanced JAVA Programming JDBC Drivers:

  • JAVA applications use the JDBC API to connect with a database through a database driver. Most database engines have different types of JDBC drivers associated with them.
  • JavaSoft has defined four types of drivers.

The JDBC-ODBC Bridge:

  • The JDBC-ODBC bridge is a driver that translates JDBC calls to ODBC operations. This bridges enables all DBMS that support ODBC to interact with JAVA applications.
  • The figure given below shows the layers in aJDBC application that uses the ODBC bridge.

Elements of Advanced JAVA Programming

  • The JDBC-ODBC bridge interface is provides as a set of the C-shared dynamic libraries. ODBC provides a client side set of libraries and a driver specific to the client’s operating system.
  • These ODBC calls are made as C calls, and the client must have a local copy of that ODBC driver and associated client-server libraries. This places a restriction on its usage in web based applications.

Sourabh Bhunje

Sourabh Bhunje, B.E. IT from Pune University. Currently Working at Techliebe. Professional Skills: Programming - Software & Mobile, Web & Graphic Design, Localization, Content Writing, Sub-Titling etc. http://techliebe.com/about-us

Leave a Reply