Advanced Java:: Archi by Distributing Multiple Machines)
Advanced Java:: Archi by Distributing Multiple Machines)
1.JDBC
2.SERVLETS(WEB TECHNOLOGY)
3.JSP(WT)
FOR DATABASE:
1.ORACLE
2.MYSQL
II)GUI-GRAPHICAL USER INTERFACE IT IS LIKE A NEW WINDOW APPREARS IN SCREEN AND WE HAVE
TO INPUT VALUES IN THAT
CUI and GUI are user interface used in connection with computers. • CUI is the precursor
of GUI and stands for character user interface where user has to type on keyboard to
proceed. On the other hand GUI stands for Graphical User Interface which makes it
possible to use a mouse instead of keyboard
An applet is a program written in the Java programming
language that can be included in an HTML page, much in the same way
an image is included in a page. When you use a Java
technology-enabled browser to view a page that contains an applet,
the applet's code is transferred to your system and executed by the
browser's Java Virtual Machine (JVM).
Applets are Java programs which are capable of being run
within a browser. Swing is a GUI framework.
2. Applet belongs to java.awt package and swing belongs to
javax.swing.* package.
3. Applet is a heavy weight component but swing comes under
light weight component's category.
2.ENTERPRISE OR DISTRIBUTED APPS:
->THE MAIN PURPOSE OF THIS TO GENERATE DYNAMIC RESPONSE FROM RECEIVED STATIC
RESPONSE.
THIS IS EXECUTED BY ONLY APP SERVER.BCZ APP SERVER HAS THE MIDDLE WARE
SERVICES(JAAS,JNDI,JTA).
EG:APPLET,GUI
->THIS IS TO ESTABLISH COMMUNICATION BET LOCAL MACHINE AND REMOTE MACHINE INORDER
TO GET REMOTE SERVICES FROM REMOTE MACHINES.
NOTE : ON COMBINING THE ARROW POINTS CONSIDER
PLACING ORDER IN AMAZON AND PAYING AMOUNT
THROUGH THE BANK SERVER.
THE MAIN INTENTION OF SERVLET AND JSP IS TO
DESIGN A WEB APPLICATION TO GENERATE DYNAMIC
RESPONSE FROM SERVER MACHINE.
TWO TYPES OF RESPONSE:
1.STATIC
NOT GENERATING A RESPONSE FROM SERVER
EG: CONSIDER FB WHEN 100 PEOPLE ARE ENTERING LOGIN PAGE IT JUST
SHOWS UP THE PAGE WITHOUT ANY SERVER MACHINE help. (.html files)
2.DYNAMIC
GENERATING A RESPONSE FROM SERVER(by the WEB APP AND THIS IS DEVELOPED BY WEB
TECHNOLOGIES)
Eg:in the same eg when we are typing our own mail id and password then it
has some server machine operations .
NOTE: WHY WE ARE GOING TO SERVLETS WHILE CGI(COMMON GATEWAY
INTERFACE ) IS AVAILABLE?
TO ANS THIS,CGI IS DESIGNED BY C PRG LANG SO IT IS PROCESS BASED
PRGMING.WHEN MULTIPLE REQUEST ARE SENT TO SERVER IT CREATES
SEPARATE PROCESS TO EXECUTE IT ,IT IS HEAVY WEIGHT(CONSUMES MORE
MEMORY )
AND THE EXE TIME IS LONG FINALLY ITS EFFICIENCY REDUCES.
SERVLET IS JUST OPPOSITE TO THE CGI,IT CREATES THREAD FOR EVERY
REQUEST ,TAKES LESS MEMORY AND LESS TIME.
DIFFERENCE BETWEEN JSP(JAVA SERVER PAGE) AND SERVLET:
IF WE KNOW JAVA BASICS WE CAN USE SERVLET
ELSE IF WE DON’T KNOW JAVA WE CAN USE JSP(SCRIPTING LANGUAGE CAN BE
EASILY UNDERSTANDABLE).
BUT ONLY JSP IS NOT REQUIRED TO BUILD WEB APPS.
WHERE TO USE SERVLET(USED IN PROCESSING):TO TAKE REQUEST FROM
CLIENT AND PROCESS(BUSINESS LOGIC) IT.
AND JSP(USED IN PRESENTATION):TO GENERATE DYNAMIC RESPONSE WITH
VERY GOOD LOOK AND FEEL.
EG:CONSIDER LOGIN PAGE ,USERNAME AND PASS ARE PROCESSED BY SERVLET
AND THEN THE STATUS OF LOGIN SUCCESSFUL OR FAILURE IS PRESENTED BY
JSP.
IF WE USE ONLY SERVLET THEN WE CANNOT PRESENTATION AND BUSINESS
LOGIC.
IF WE USE ONLY JSP THEN WE CAN SEPARATE BOTH LOGICS BCZ IT HAS HTML
TAGS AND JSP TAGS FOR BUSINESS LOGIC.
JDBC Drivers
Java Database Connectivity (JDBC) is an application programming interface (API)
for the programming language Java, which defines how a client may access any kind
of tabular data, especially relational database. It is part of Java Standard Edition
platform, from Oracle Corporation. It acts as a middle layer interface between java
applications and database.
The JDBC classes are contained in the Java Package java.sql and javax.sql.
JDBC helps you to write Java applications that manage these three programming
activities:
1. Connect to a data source, like a database.
2. Send queries and update statements to the database
3. Retrieve and process the results received from the database in answer to your query
Structure of JDBC
Do You Know
o How to connect Java application with Oracle and Mysql database using JDBC?
o What is the difference between Statement and PreparedStatement interface?
o How to print total numbers of tables and views of a database using JDBC?
o How to store and retrieve images from Oracle database using JDBC?
o How to store and retrieve files from Oracle database using JDBC?
What is API
https://www.tutorialspoint.com/jdbc/index.htm
JDBC Driver is a software component that enables java application to interact with the
database. There are 4 types of JDBC drivers:
1. JDBC-ODBC bridge driver
2. Native-API driver (partially java driver)
3. Network Protocol driver (fully java driver)
4. Thin driver (fully java driver)
Oracle does not support the JDBC-ODBC Bridge from Java 8. Oracle recommends that
you use JDBC drivers provided by the vendor of your database instead of the JDBC-
ODBC Bridge.
Advantages:
o easy to use.
o can be easily connected to any database.
Disadvantages:
o Performance degraded because JDBC method call is converted into the ODBC
function calls.
o The ODBC driver needs to be installed on the client machine.
2) Native-API driver
The Native API driver uses the client-side libraries of the database. The driver converts JDBC method
the database API. It is not written entirely in java.
Advantage:
o performance upgraded than JDBC-ODBC bridge driver.
Disadvantage:
o The Native driver needs to be installed on the each client machine.
o The Vendor client library needs to be installed on client machine.
next →← prev
JDBC Driver
1. JDBC Drivers
1. JDBC-ODBC bridge driver
2. Native-API driver
3. Network Protocol driver
4. Thin driver
JDBC Driver is a software component that enables java application to interact with the database.
drivers:
1. JDBC-ODBC bridge driver
2. Native-API driver (partially java driver)
3. Network Protocol driver (fully java driver)
4. Thin driver (fully java driver)
1) JDBC-ODBC bridge driver
The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC brid
method calls into the ODBC function calls. This is now discouraged because of thin driver.
Oracle does not support the JDBC-ODBC Bridge from Java 8. Oracle recommends that you use JDBC
vendor of your database instead of the JDBC-ODBC Bridge.
Advantages:
o easy to use.
o can be easily connected to any database.
Disadvantages:
o Performance degraded because JDBC method call is converted into the ODBC function calls.
o The ODBC driver needs to be installed on the client machine.
2) Native-API driver
The Native API driver uses the client-side libraries of the database. The driver converts JDBC meth
the database API. It is not written entirely in java.
Advantage:
o performance upgraded than JDBC-ODBC bridge driver.
Disadvantage:
o The Native driver needs to be installed on the each client machine.
o The Vendor client library needs to be installed on client machine.
The Network Protocol driver uses middleware (application server) that converts JDBC calls directly or
specific database protocol. It is fully written in java.
Advantage:
o No client side library is required because of application server that can perform many tasks lik
logging etc.
Disadvantages:
o Network support is required on client machine.
o Requires database-specific coding to be done in the middle tier.
o Maintenance of Network Protocol driver becomes costly because it requires database-specific
middle tier.
4) Thin driver
The thin driver converts JDBC calls directly into the vendor-specific database protocol. That is why it
It is fully written in Java language.
Advantage:
o Better performance than all other drivers.
o No software is required at client side or server side.
Disadvantage:
o Drivers depend on the Database.
Note: Since JDBC 4.0, explicitly registering the driver is optional. We just need to
put vender's Jar in the classpath, and then JDBC driver manager can detect and
load the driver automatically.
1. Class.forName("oracle.jdbc.driver.OracleDriver");
TO KNOW HOW TO CONNECT MYSQL DATABASE USING JDBC SEE THIS VIDEO:
https://www.youtube.com/watch?v=yeefScqwi0g