Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Jody Mills   on Apr 26 In Java Category.

  
Question Answered By: Ziza Mizrachi   on Apr 26

sun.jdbc.odbc.jdbcodbcdriver <-- this is the fully
qualified name of a class..this class  also happens to
be the implementation of the JDBC-ODBC driver which is
shipped defaullt in the JDK kits from sun.

If I have written my own implementation of a JDBC
Driver and named the class as cm.vijay.MyDriver then
my code will be

Class.forName("com.vijay.MyDriver");

Also an observation ...it is a good practice to call
the newInstance() so that the call will look like

Class.forName("sun.jdbc.odbc.jdbcodbcdriver").newInstance();

I have read reports that some of the JVM's have a bug
that does not properly execute static blocks....ans
the call to newInstance() will make them execute
properly.

With respect to the DriverManger..this classes fully
Qualified name is

java.sql.DriverManager

<Taken From the JDK Docs>
<Start>
As part of its initialization, the DriverManager class
will attempt to load the driver classes referenced in
the "jdbc.drivers" system property. This allows a user
to customize the jdbc  Drivers used by their
applications. For example in your
~/.hotjava/properties file you might specify:


jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver
A program can also explicitly load JDBC drivers at
any time. For example, the my.sql.Driver is loaded
with the following statement:
Class.forName("my.sql.Driver");
When the method getConnection is called, the
DriverManager will attempt to locate a suitable driver
from amongst those loaded at initialization and those
loaded explicitly using the same classloader as the
current applet or application.
</END>
</Taken From the JDK Docs>

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on What is DriverManager class Or get search suggestion and latest updates.


Tagged: