Chapter 6.VI Interacting With Database
Chapter 6.VI Interacting With Database
Two-Tier Model
In the two-tier model, a Java applet or application talks directly to the data
source. This requires a JDBC driver that can communicate with the particular
data source being accessed. A user's commands are delivered to the database or
other data source, and the results of those statements are sent back to the user.
The data source may be located on another machine to which the user is
connected via a network. This is referred to as a client/server configuration, with
the user's machine as the client, and the machine housing the data source as the
server. The network can be an intranet, which, for example, connects employees
within a corporation, or it can be the Internet.
Three-tier Architecture
Until recently, the middle tier has often been written in languages such as
C or C++, which offer fast performance. However, with the introduction
of optimizing compilers that translate Java bytecode into efficient
machine-specific code and technologies such as Enterprise JavaBeans™,
the Java platform is fast becoming the standard platform for middle-tier
development. This is a big plus, making it possible to take advantage of
Java's robustness, multithreading, and security features.
What is JDBC Driver?
The DriverManager class acts as an interface between user and drivers. It keeps track of
the drivers that are available and handles establishing a connection between a database
and the appropriate driver. The DriverManager class maintains a list of Driver classes
that have registered themselves by calling the method DriverManager.registerDriver().
Method Description
1) public static void is used to register the given driver with
registerDriver(Driver driver): DriverManager.
2) public static void is used to deregister the given driver
deregisterDriver(Driver driver): (drop the driver from the list) with
DriverManager.
3) public static Connection is used to establish the connection with
getConnection(String url): the specified url.
4) public static Connection is used to establish the connection with
getConnection(String url,String the specified url, username and
userName,String password): password.
Connection interface