Loading Of JDBC Driver
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Wednesday, August 25, 2004 11:01 AM

			What actually happens behind the scenes when Class.forName() method is called.
What is meant by the driver "registers" with the DriverManager class.
What does the term "registers" imply in this context.
These two questions has been bothering me for long time. Could some one give me detail explanation ??. Wud appreciate

Re: Loading Of JDBC Driver

Posted By:   Amir_Pashazadeh  
Posted On:   Thursday, August 26, 2004 02:21 AM


Class.forName() just forces a ClassLoader to load a class with the name you specified and nothing more.

Most of java.sql.Driver implementations (I think this is a must) have s static initializaiton block in their classes (which is invoked when class is being loaded by ClassLoader) which registers them to java.sql.DriverManager.

In fact nothing magical happens at all, you order to load the class by calling Class.forName(), class loader loads the class and runs static initialization block of it, and there is the code which registers driver class to DriverManager.

Amir Pashazadeh

About | Sitemap | Contact