JAVA DATABASE CONNECTIVITY (JDBC):
from http://java.sun.com/products/jdk/1.1/docs/guide/jdbc/getstart/intro.doc.html#1005262
Simply put, JDBC makes it possible to do three things:
establish a connection with a database
send SQL statements
process the results.
The following code fragment gives a basic example of these
three steps:
Connection con =
DriverManager.getConnection (
"jdbc:odbc:wombat", "login", "password");
Statement stmt =
con.createStatement();
ResultSet rs =
stmt.executeQuery("SELECT a, b, c FROM Table1");
while (rs.next())
{
int x =
rs.getInt("a");
String s =
rs.getString("b");
float f =
rs.getFloat("c");
}
JDBC is a "low-level" interface, which means that
it is used to invoke (or "call") SQL commands directly. It works very
well in this capacity and is easier to use than other database connectivity
APIs, but it was designed also to be a base upon which to build higher-level
interfaces and tools. A higher-level interface is "user-friendly,"
using a more understandable or more convenient API that is translated behind
the scenes into a low-level interface such as JDBC.
=
At this point, Microsoft's ODBC (Open DataBase Connectivity)
API is probably the most widely used programming interface for accessing
relational databases. It offers the ability to connect to almost all databases
on almost all platforms. So why not just use ODBC from Java?
The answer is that you can use ODBC from Java, but this is
best done with the help of JDBC in the form of the JDBC-ODBC Bridge, which we
will cover shortly.
=
The JDBC API supports both two-tier and three-tier models
for database access.
In the two-tier model, a Java applet or application talks
directly to the database. This requires a JDBC driver that can communicate with
the particular database management system being accessed. A user's SQL
statements are delivered to the database, and the results of those statements
are sent back to the user. The database 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 database as the server.
=
In the three-tier model, commands are sent to a "middle
tier" of services, which then send SQL statements to the database. The
database processes the SQL statements and sends the results back to the middle
tier, which then sends them to the user. MIS directors find the three-tier
model very attractive because the middle tier makes it possible to maintain
control over access and the kinds of updates that can be made to corporate
data. Another advantage is that when there is a middle tier, the user can
employ an easy-to-use higher-level API [ with its GUIs on the client machine ]
which is translated by the middle tier into the appropriate low-level calls.
Finally, in many cases the three-tier architecture can provide performance
advantages.