Advance JAVA


 Advanced Java is everything that goes beyond Core Java – most importantly the APIs defined in Java Enterprise Edition, includes Servlet programming, Web Services, the Persistence API, etc. It is a Web & Enterprise application development platform which basically follows client & server architecture.

Advanced Java Tutorial: Need for Advance Java

Below I have listed down few major advantages of Advance Java:

  1. Advance Java i.e. JEE (Java Enterprise Edition) gives you the library to understand the Client-Server architecture for Web Application Development which Core Java doesn’t support.
  2. J2EE is platform Independent, Java Centric environment for developing, building & deploying Web-based applications online. It also consists of a set of services, APIs, and protocols, which provides the functionality that is necessary for developing multi-tiered, web-based applications.
  3. You will be able to work with Web and Application Servers like Apache Tomcat, Glassfish etc and understand the communication over HTTP protocol. But, in Core Java, it is not possible.
  4. There are a lot of Advance Java frameworks like Spring, JSF, Struts etc. which enable you to develop a secure transaction based web apps for the domains like E-Commerce, Banking, Legal, Financial, Healthcare, Inventory etc.
  5. To work and understand the hot technologies like Hadoop and Cloud services, you should be prepared with core and advanced Java concepts.

I hope you understood why Advanced Java is essential. For your better understanding, I have divided this article into three sections. Each of these section deals with one of the most important concepts of advanced Java:

  1. JDBC (Java DataBase Connectivity)
  2. Java Servlets
  3. JSP (Java Servlet Pages)

So, now let’s begin our discussion and understand the concept of Java Database Connectivity, a helpful tool to interact with the database.

Advanced Java Tutorial: Introduction to JDBC

JDBC is a standard Java API for a database-independent connectivity between the Java programming language and a wide range of databases. This application program interface lets you encode the access request statements, in Structured Query Language (SQL). They are then passed to the program that manages the database. It mainly involves opening a connection, creating a SQL Database, executing SQL queries and then arriving at the output.

We can use JDBC API to access tabular data stored in any relational database. By the help of JDBC API, we can save, update, delete and fetch data from the databases. It is similar to the Open Database Connectivity (ODBC) provided by Microsoft.

For a better understanding of working of JDBC, let’s dive deeper into the topic and understand the architecture that lies behind Java Database Connectivity.

Advanced Java Tutorial: JDBC Architecture

The JDBC API supports both two-tier and three-tier processing models for database access but in general, JDBC Architecture consists of two layers −

  • JDBC API: This provides the application-to-JDBC Manager connection.
  • JDBC Driver API: This supports the JDBC Manager-to-Driver Connection.

JDBC Architecture - Advanced Java - Edureka

The JDBC API uses a driver manager and database-specific drivers to provide transparent connectivity to heterogeneous databases. The JDBC driver manager ensures that the correct driver is used to access each data source. The driver manager is capable of supporting multiple concurrent drivers connected to multiple heterogeneous databases.

Advanced Java Tutorial: Common JDBC Components

The JDBC API provides the following interfaces and classes −

  • DriverManager is used to manage a list of database drivers. The first driver that recognizes a certain subprotocol under JDBC will be used to establish a database Connection.
  • Driver is an interface that handles the communications with the database server. It also abstracts the details associated with working with Driver objects.
  • Connection is an interface that consists all the methods required to connect to a database. The connection object represents communication context, i.e., all communication with the database is through connection object only.

Now let’s move on to the next topic and look at the steps required to create a JDBC Application.

Advanced Java Tutorial: Steps to create JDBC Application

In order to create JDBC Application, we need to follow few steps. Let’s see what are they.

Steps to create JDBC Application - Advanced Java tutorial - Edureka

  1. Import the packages: You need to include the packages containing the JDBC classes needed for database programming. Most often, using import java.sql.* will suffice.
  2. Register the JDBC driver: Here you have to initialize a driver so that you can open a communication channel with the database.
  3. Open a connection: Here, you can use the getConnection() method to create a Connection object, which represents a physical connection with the database.
  4. Execute a query: Requires using an object of type Statement for building and submitting an SQL statement to the database.
  5. Extract data from result set: Requires that you use the appropriate getXXX() method to retrieve the data from the result set.
  6. Clean up the environment: Requires explicitly closing all database resources versus relying on the JVM’s garbage collection.

Now as you have seen various steps involved to create a JDBC Application, let’s see an example code to create a database and establish a connection.



Comments