Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Type 2 Vs Type 4 JDBC DRIVER Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Type 2 Vs Type 4 JDBC DRIVER" Watch "Type 2 Vs Type 4 JDBC DRIVER" New topic
Author

Type 2 Vs Type 4 JDBC DRIVER

Sudhanshu Mishra
Ranch Hand

Joined: May 28, 2011
Posts: 217

Hi all,
I have a question regarding jdbc drivers.
Why is it that Type 4 is good for internet applications as compared to type 2?The confusion is that in both the case we need to install something in the client machine: in the type 2 driver we install native db libraries in client machine,which makes it database specific,and in type 4 we use the driver corresponding to a database.So in both the cases,drivers are DBMS dependent.
So why is it that type 4 is better than type 2 for internet applications?
Thanks........
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

Non-Java drivers are not only database specific, but also platform specific and furthermore, often require a configuration of their own (eg. standard Oracle database client - TNSNAMES.ORA etc.). Whereas Java-only drivers indeed are database specific, but once bundled into your project, do not require further driver installation or configuration.

So unless your application really needs something that only a native driver can provide (eg. some of the few functionalities supported by the type 2 driver only for Oracle), I'd say type 4 driver is always easier to use than type 2 driver, regardless of the character of the application. Though the DB vendor might provide some means to bundle the type 2 driver with the application (I think Oracle does have something like this), you still have the platform dependency, which is often a clear disadvantage and in any case one more thing to learn and maintain.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Type 2 Vs Type 4 JDBC DRIVER