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?

Showing Answers 1 - 15 of 15 Answers

Umanath MCA

  • Nov 1st, 2007
 

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

  Was this answer useful?  Yes

sampra

  • Feb 11th, 2008
 

This is a static method of class Class and we can call by class anme directly  its task is to load the class in to the memory   

  Was this answer useful?  Yes

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.

  Was this answer useful?  Yes

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.


Thanks,
Vinay

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions