| Author |
Class.forName()
|
Saurabh Naik
Ranch Hand
Joined: Apr 24, 2008
Posts: 87
|
|
Hello Ranchers..
I am confused in Class.forName() method.. As per my knowledge after calling this method it gets availabe class file of particular driver. e.g - OracleDriver.class . but we never invoked any method on it. so what is the use of it. please explain ..
Thanks in Advance
|
SCJP 6 (88%), SCWCD 5 (78%), preparing for SCBCD
|
 |
Balu Sadhasivam
Ranch Hand
Joined: Jan 01, 2009
Posts: 874
|
|
Saurabh,
Class.forName() is used to load classes. When a class is loaded , it calls static initializes block. And drivers like OracleDriver when loaded , initializes in static initializers and registers itself with DriverManager. HTH
|
 |
dariyoosh za
Greenhorn
Joined: Apr 12, 2009
Posts: 18
|
|
Saurabh Naik wrote:Hello Ranchers..
I am confused in Class.forName() method.. As per my knowledge after calling this method it gets availabe class file of particular driver. e.g - OracleDriver.class . but we never invoked any method on it. so what is the use of it. please explain ..
Thanks in Advance
Hello there,
Since JDBC 4.0, there is no more need to call this method, as DriverManager does automatic driver loading (as long as the drivers are accessible to the current classpath)
Regards,
|
 |
Jan Cumps
Bartender
Joined: Dec 20, 2006
Posts: 2343
|
|
dariyoosh za wrote:Since JDBC 4.0, there is no more need to call this method, as DriverManager does automatic driver loading (as long as the drivers are accessible to the current classpath)
Ah. I love the ranch. Didn't know about this. Thank you for the info.
|
OCUP UML fundamental
ITIL foundation
|
 |
 |
|
|
subject: Class.forName()
|
|
|