Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification regarding Drivers

 
rajaraman navaneethan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
i am a novice in JDBC, and i have just started to explore it in detail.i understand that there are 4 types of JDBC drivers like Type1,2,3,4 and other database drivers like ODBC.from various material available i understand that Driver is an interface which is used as a middleman between the Java Program and the Database.
it is being told that the implementations for Drivers are provided by respective vendors.i dont understand whom do they refer by vendors.I guess that the implementations for JDBC drivers Type1,2,3,4 is given by Sun and for drivers like ODBC is given by respective database vendors.
Do the implementations for interfaces like Statement,PreparedStatement,etc are also provied by Sun?
kindly clarify my doubts
thanx & regards
Raja
 
Sunil Dumpala
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajaraman,

Drivers 1,2,3,4 are more generic way to define a driver. Any given driver has to be one of the 1,2,3,4 type Driver (even the ODBC driver).

Yes, Sun provides tutorials for using PreparedStatememnt, CallableStatement etc.,
For example the following link is tutorial for using PreparedStatement

http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html

Thanks,
Sunil Dumpala
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rajaraman navaneethan:
I dont understand whom do they refer by vendors.


vendor means driver provider, more the times It driver provider is same as database provider and referred commonly as vendor.

As a example if you are using classes12.zip to connect oracle then in
this case DB provider is Oracle and since classes12.zip is given by Oracle so driver provider is also Oracle.

Similarly implementions of other interfaces like PreparedStatement,Statement and other interface are also given by driver provider

for exaplme if you are using sql server and using driver provided by MicroSoft then your both DB provider and driver Provider would be same but you can also use jTDS to connect with SQL Server in this case you Driver provider would change,It would be now jTDS and implemntation of all interface would be given by jTDS driver

Hope this clears you confusions

Shailesh
[ September 16, 2005: Message edited by: Shailesh Chandra ]
 
rajaraman navaneethan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Shailesh,Sunil,
thanx for your quick replies.
Shailesh, i am using JDBC-ODBC bridge driver, to connect to MS Access database.i write simple jdbc programs using Statement and Prepared Statement.so the implementations for these are provided by MSAccess itself.
Shailesh please confirm if my understanding is correct.

regards
Raja
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JDBC-ODBC bridge is an exception - it is part of the JDK itself. Most other drivers are provided by the database vendors, though, except for commercial third-party ones.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Ulf Dittmer !!!

rajaraman If you look back at your code you might be registering your driver like


here you are using JdbcOdbcDriver to establish a connection means your driver provider is sun and sun offers this driver as a part of JDK, eventually same thing what Ulf Dittmer said.

hope this clear your understanding

Shailesh
 
rajaraman navaneethan
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sailesh,
thanx for the replies.i understand that type-1 driver implementation is given by Sun.can u please give me examples for loading any other drivers like type-2,3,4 whose implementations are provided by the database vendors?
regards
Raja
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following assumes that 'thanx' means 'thanks' and 'u' means 'you. We try to prevent misunderstanding by using real words.

can u please give me examples for loading any other drivers like type-2,3,4 whose implementations are provided by the database vendors?

Loading a Type-1 Driver:

Loading a Type-2 Driver:

Loading a Type-3 Driver:

Loading a Type-4 Driver:


I'm not teasing you here, this is one of the strengths of JDBC: changing Driver types or even vendors is often just a matter of changing the loaded Driver and JDBC URL! If written carefully you may not need to rewrite a single line of code!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic