Saturday, September 18, 2021

What is API (Application Programming Interface) in java

 What is API in J2EE

java in API
java (J2EE)


API stands for an Application programming interface. it is used for inter-Application communication. API is used for " inter-application communication " i.e one application can communicate with another application with the help of API to achieve loose coupling.

loose coupling means classes are independent of each other.

The backbone of API is Abstraction.

Example of API

Apache POI, Jaxcel, JDBC-API Servlet-API etc.

contents of API's

The contents of API are interface, helper class, and implementation class given in the form of the ".jar" file.

There are two different forms of Api

  1. First form of API.
  1. Second forms of API.

1)  First form of API:-

This form of API contains interfaces, Helper class, implementation class in the form of the .jar file. This form of API is exposed to developers only to write logic or code.
Eg:-
Apache POI, Jaxcel, etc.

2) Second form of API:-

Eg:- JDBC Api, Servlet Api etc

 JDBC API:-

  • JDBC API contains interfaces and Helper Classes in the form of jar file.
  • If i want to develop any JDBC Application, we need JDBC API because it provides several interfaces and Helper Class which is used for database Communication.
  • Implementation classes is provided by the respective DataBase Vendors(Owner).
  •  JDBC API is distributed in 2 different packages

  1.  java.sql
  2. javax.sql


1) javax.sql

 It is an extension of java.sql, it contains several or some additional interfaces than java.sql.

A few of the interfaces of JDBC API are:-
a) Driver
b) Connection
c) Statement
d) PreparedStatement
e) CallableStatement
f) ResultSet
etc......

 JDBC API contains only one HelperClass in it...
DriverManager

JDBC Driver:-

  •  JDBC Driver is an implementation of JDBC API.
  • JDBC Driver contains implementation classes.
  • JDBC Driver is always specific to a particular DB Server/Vendor.
  • JDBC Driver is provided by the respective DB Server/Vendor.

Advantage of JDBC:-

We can achieve loose coupling between the java application and db server.

Port Number:-

 port no is the one which helps us to get connected with a particular server.

Oracle ---> 1521
my-sql ---> 3306
ms-sql ---> 1433
Derby ---> 1527

0 comments:

If you have any doubts,please let me know