Java Reference
In-Depth Information
10. Click the OK button in the ODBC Data Source Administrator dialog box.
Click the Close button on the Administrative Tools window title bar.
The ODBC data source name is registered and the ODBC data source is
available for use.
Once an ODBC data source exists, a connection to the database may be
established. This connection is made within a Java program by using JDBC™.
Connecting to a Database Using JDBC™
A major benefit of using JDBC™ is interoperability , which means the
underlying database used in an application can change with essentially no
change to the application. Using the JDBC™ API to access a database keeps the
application isolated from the peculiarities of a specific DBMS, as long as an
appropriate driver is used. A JDBC™ driver is software for a specific DBMS and
effectively translates between the functionality of the JDBC™ API and the
corresponding commands of the DBMS. The application program uses the
JDBC™ API, keeping the Java code consistent regardless of the DBMS used;
JDBC™, in turn, communicates to the DBMS through the specific JDBC™
driver. Table 11-4 lists the four types of JDBC™ drivers.
Table 11-4
JDBC™ Driver Types
TYPE
NAME
DESCRIPTION
PROS
CONS
Type 1
JDBC-ODBC
Calls go through Bridge,
Access to many databases
Performance degraded;
Bridge
then to driver, then to
through ODBC drivers
ODBC, ODBC driver
native database interface
needed for specific
database on local (client)
machine
Type 2
Native-API/
Variation on JDBC-ODBC
Better performance than
Requires binary code
partly Java
bridge, but converts JDBC
Bridge
(vendor database library)
calls into database-specific
on client machine; lower
calls and so communicates
performance than Types
directly with database
3 and 4
server
Type 3
net-protocol/
Three-tiered; translates calls
Can handle multiple Java
Requires database-specific
all-Java
into DBMS-independent
clients connecting to
coding in middle tier;
net protocol, then
multiple databases; sup-
traversing query result
translated to DBMS
ports advanced features,
sets may take longer
protocol by middleware
such as logging, auditing,
due to path through
server
caching, and load-
backend server
balancing; in general,
the most flexible solution
Type 4
Native
Similar to Type 2 but
Performance; no special
Needs different driver for
protocol/
100% Java; converts JDBC
client or server software
each database
all Java
calls into native calls for
needed; drivers can be
database
downloaded dynamically
 
Search WWH ::




Custom Search