what exactly happens when we execute
"Class.forname("Driver class name");"?Explain indetail

Answers were Sorted based on User's Feedback



what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / sangeeta

Class is a predefined class and forName is the static
method of the class which is used to load the driver in the
memory for connectivity.

For eg
Class.forName("sun.jsbc.odbc.JdbcOdbcDriver");

Is This Answer Correct ?    26 Yes 1 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / srinivas.r, -parigi

Class is predefined class and .forName() is the static
method , it is responsiblity of jdbc Driver implementer to
provide a static block as part of the driver class.As part
of this sttic block code will be provided to take care of
registering the driver
EX : --------------****--------
public class Drv implements Driver
{
static{Driver d=new OracleDriver();
DriverManager.register(driver);
}}
----------------*******--------
As the sttic block provided by the driver vender can take
care of registering the driver instance of following code
----------
Driver drv=new Oralce.jdbc.driver.OracleDriver();
DriverManager.registerDriver(driver);
----------
by providing directly
Class.forName("oralce.jdbc.driver.OracleDriver");
the above code will be executed.........All the best.
------- Thank u to providing this facility

Is This Answer Correct ?    12 Yes 0 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / nitin upadhyay,raigarh(c.g)

By using this coding we load the driver.
Class is a predefined class and forName is the static
method of the class. which is used to load the driver in the
memory for connectivity.

For eg
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Is This Answer Correct ?    13 Yes 2 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / ram

Guyz,
As Srinivas.r -parigi and Yash already given the straight
forward answer. Nothing i could say.

Thanks Srinivas.r -parigi for giving the best answer.

Is This Answer Correct ?    6 Yes 0 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / prabhakaran

Class is a predefined class and forName is the static
method of the class which is used to load the driver
dynamically in the client machine at runtime

Is This Answer Correct ?    6 Yes 1 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / yash

In addition to above answers, using Class.forName the
instance of driver is automatically registered with the
DriverManager. Thus it saves us from the efforts of
creating new instance of driver and registering it with
DriverManager!!

Is This Answer Correct ?    8 Yes 3 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / shital

Class is a predefined class & foreName is a static method
to load the driver for connectivity

Is This Answer Correct ?    5 Yes 0 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / girija shankar shadangi

this method creates object of driver class(which contains all he data like address of a driver and all the details of the driver)and registers the object to the JVM.it means making the object available to the jvm,so that jvm can use this object for its further operation internally.

Is This Answer Correct ?    4 Yes 0 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / sudhakar

By the end of the execution of Class.forName("Driver
class"); the driver class should be loaded into the memory
but also
1. The driver class should be initialized
2. Should be registered with the driver manager class
The above two operations are not done by forName() . So a
pure Static() block is defined in which the above two tasks
are manipulated and by which we are able to get connection,
immediately after loading the driver class without writing
any code to initialize the driver class.

Is This Answer Correct ?    4 Yes 1 No

what exactly happens when we execute "Class.forname("Driver class name");"?Expl..

Answer / devarathnam c,kotagudibanda(po

Hi... Actually whenever the JVM encounter the statement
Class.forName("Driver class name");The drivers will be
loading into the memory,then only the JVM will identify the
driver to process the database stuff.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More JDBC Interview Questions

Explain the two tier and three tier architecture of jdbc.

0 Answers  


HI ALL, How to Overcome "OutOfMemoryException"? when I am compiling source having more than 1000 LOC throwing this exception. Can any one give correct answer to my question? thx

5 Answers  


Are all the required JDBC drivers to establish connectivity to my database part of the JDK?

0 Answers  


Name the types of jdbc drivers.

0 Answers  


what exactly happens when we execute "Class.forname("Driver class name");"?Explain indetail

10 Answers   Accenture, HP, IBM, Infosys, SAP Labs, SAS, Sasken, Trigent, Wipro,






What is a connection string used for?

0 Answers  


Explain the steps in writing a java program using jdbc?

0 Answers  


What is a jdbc url?

0 Answers  


Why do we use jdbc in java?

0 Answers  


What is JDBC Driver interface?

0 Answers  


How to connect html page to database using jdbc?

0 Answers  


explain about special characters?

0 Answers  


Categories