|
|
论坛精华
>> JDBC
>> JDBC Driver Types
由 george 发布于: 2001-03-03 03:53
<font color=blue>JDBC Driver Types</font>
When you take an interview with a teamleader, the following question are always asked.
1)How many kinds of JDBC driver in java?
2)Which type do you use in your projects?
3)Whick kinds of driver are there in Oralce Database?
Now, I answer these questions by explaining the JDBC driver types as the followings.
Sun has defined 4 JDBC diver types:
JDBC-ODBC Bridge, plus ODBC driver
Native-API, partly-Java Driver
JDBC-net, pure Java driver
Native-protocol, pureJava driver
Each of these types meets a different application need.
Type1: JDBC-ODBC Bridge, plus ODBC driver
This driver type is provided bt SUn with he JDK1.1 and later.It provides JDBC access to database through ODBC drivers. The ODBC driver must be configured on the client for the bridge to work. This driver type is commonly used <font color=red>for prototying or when there is no other JDBC drivers availible for DBMS. see the following figure.
Type 2:Native-API Driver
The native-API driver JDBC commands into DBMC-specific native calls. This is muck like the restriction of type 1 driver. The client must have some binary code loaded on its machine. These driver has better performance than type1 driver, becoz they interface directly with the database. see the figure.
Type 3: JDBC-Net Pure Java Driver
The JDBC-Net drivers are a 3-tier solution.( I drew a skeleton of 3-tier solution in the last article)JDBC calls into a database-independent network protocol that is sent to a middleware server.This server then translates this protocol intoa DBMS-specific protocol, which is sent to a particular database. The results sre sent back to client by routing through middleware server. This tyoe makes it possible to implement a pure Java client. It also makes it possible to swap db without affecting the client. This is by far the most flexible JDBC solution.
Type 4: Native-Protocol, pure JavaDriver
In morjority of chinese translated books, NATIVE is translated to seem like "local" or other meaning. I nmy view, it is an error. Native is not local and should be thought as other programs written by other languages other than JAVA. SO please pay attention to and understand the meaning of NATIVE.
This type is pure java driver that communicates directly with the vendor's database. They do this by converting JDBC commands directly into the databaseengine's native protocol. This type driver has a very distinct advantage over all the other driver types since it has not no addtional tranlation or middleware layers.
In some intermediate scale projects, we should use the type4 drivers, since it has the best comprised performance than others. But if you want to do just a small project, the type 2 is a choice, becoz it uses native-API which have fast execution speed.
|
资料来源: JSP001.com
|