Professional Documents
Culture Documents
Applet is a special type of program that is embedded in the webpage to generate the
dynamic content. It runs inside the browser and works at client side.
Advantage of Applet
There are many advantages of applet. They are as follows:
o Secured
Drawback of Applet
o Plugin is required at client browser to execute applet.
1. Applet is initialized.
2. Applet is started.
3. Applet is painted.
4. Applet is stopped.
5. Applet is destroyed.
java.applet.Applet class
For creating any applet java.applet.Applet class must be inherited. It provides 4 life cycle
methods of applet.
1. public void init(): is used to initialized the Applet. It is invoked only once.
2. public void start(): is invoked after the init() method or browser is maximized. It is
used to start the Applet.
3. public void stop(): is used to stop the Applet. It is invoked when Applet is stop or
browser is minimized.
4. public void destroy(): is used to destroy the Applet. It is invoked only once.
java.awt.Component class
The Component class provides 1 life cycle method of applet.
1. public void paint(Graphics g): is used to paint the Applet. It provides Graphics
class object that can be used for drawing oval, rectangle, arc etc.
1. init(): The applet's voyage starts here. In this method, the applet object is created by the
browser. Because this method is called before all the other methods, programmer can utilize
this method to instantiate objects, initialize variables, setting background and foreground
colors in GUI etc.; the place of a constructor in an application. It is equivalent to born
state of a thread.
2. start(): In init() method, even through applet object is created, it is in inactive state. An
inactive applet is not eligible for microprocessor time even though the microprocessor is
idle. To make the applet active, the init() method calls start() method. In start() method,
applet becomes active and thereby eligible for processor time.
4. stop(): In this method the applet becomes temporarily inactive. An applet can come any
number of times into this method in its life cycle and can go back to the active state (paint()
method) whenever would like. It is the best place to have cleanup code. It is equivalent to
the blocked state of the thread.
5. destroy(): This method is called just before an applet object is garbage collected. This is the
end of the life cycle of applet. It is the best place to have cleanup code. It is equivalent to
the dead state of the thread.
the init() and destroy() methods are called only once in the life cycle. But, start(), paint() and
stop() methods are called a number of times.
Types of drivers in JDBC
JDBC Driver is a software component that enables java application to interact with the
database.Thereare 4 types of JDBC drivers:
The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. This is now discouraged because of thin driver.
Advantages:
o easy to use.
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.
o
o 2) Native-API driver
The Native API driver uses the client-side libraries of the database. The driver converts JDBC method calls into native calls of the database API. It is not written entirely in java.
Advantage:
Disadvantage:
o No client side library is required because of application server that can perform many
tasks like auditing, load balancing, logging etc.
Disadvantages:
4) Thin driver
The thin driver converts JDBC calls directly into the vendor-specific database protocol. That is why it is known as thin driver. It is fully written in Java language.
Advantage:
Disadvantage: