In the Statement below class.forName(" ---");What's going onIs the driver get registred then where it is inintialized, if it is initialized & registerde there only, How?
Class is used to create Dynamic Binding, That means Your system Connections are removed after Close the connection. for example, If U use ODBC connection to connect your database, this connection only affect after the Class.forName(;;;) Please refer Class java Package For more Details
As part of Driver class the JDBC driver vendor provides a static block. As part of the static block the vendor provides the code to register the driver. When class.forName() is executed the driver class will be loaded and the static block will be executed and this block takes care of registering the driver.
Every JDBC driver vendor providing a static block for Driver classprovided by vendor. Which taking care of creating driver class object and registaring driver class , so instead of writing code Ex:- Driver drv=new oracle.jdbc.driver.OracleDriver(); DriverManager.registerDriver(drv); //instead of that Class.forName(); //perform same task
class.forName(" Any Class Name Here") is a static method in Class class which returns the Class object associated with the class or interface with the given string name.....
So when I say class.forName("java.lang.Interger(21)") this is equivalent to => new java.lang.Integer(21) i.e. the Integer class gets loaded and is intialized with value of 21
Now the same concept is utlized by driver providers to initialize the drivers.
In the Statement below class.forName(" ---");What's going onIs the driver get registred then where it is inintialized, if it is initialized & registerde there only, How?