what does the method Class.forName returns?

Answers were Sorted based on User's Feedback



what does the method Class.forName returns?..

Answer / m.gangadhar

Example
Class.forName("oracle.jdbc.driver.OracleDriver")

first it loads th class name at run time
second it executes the static initializer containg the code
of driver class i.e
static
{
try{
DriverManager.registerDriver(new Driver());
}
catch(Exception e){}
}

then it creates the object for the driver class and
registers that object in to the DriverManager

Is This Answer Correct ?    15 Yes 1 No

what does the method Class.forName returns?..

Answer / priyank jain

Static method Class.forName(String className) returns the
Object for the classname specified in argument passed to
method.
Also Class.forName used to load drivers.
Ex. In JDBC call
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
automatically creates an instance of a EmbeddedDriver and
registers it with the DriverManager.

Is This Answer Correct ?    15 Yes 5 No

what does the method Class.forName returns?..

Answer / choudarygariabbai

static Class<?> forName(String className)
Returns the Class object associated with the
class or interface with the given string name.

Is This Answer Correct ?    8 Yes 2 No

what does the method Class.forName returns?..

Answer / uv

When Class.forName("<classname>") function gets
executed,the class gets loaded in JVM.

To create an object and access its functions and variables,
we can use getInstance( ), please look into the below
fragment code:

Class c = Class.forName("Cls");
Object o = null;
o = c.getInstance( );
// type casting the Object
Cls cl = (Cls) o;

Is This Answer Correct ?    7 Yes 1 No

Post New Answer

More JDBC Interview Questions

In JDBC, All the API?s are interfaces? Where is the actual implementation?

3 Answers   HCL,


What is database deadlock ? How can we avoid them?

0 Answers  


How many locking systems are there in jdbc?

0 Answers  


How to update a resultset programmatically?

0 Answers  


Explain the difference between inner and outer join ?

0 Answers  






What is the return type of class.forname() method?

0 Answers  


What is Type-3 Driver and when this driver is used?

3 Answers   Wipro,


What is jdbc oracle thin?

0 Answers  


Why “no suitable driver” error occurs?

0 Answers  


Which database is used for java?

0 Answers  


What is a jdbc connection string?

0 Answers  


Hi to all.. well i want to make a standalone application which can use the concept of connection pooling, constraint is that i have not to use any application server like weblogic etc. Please help me out. Thaks in advance.

3 Answers   Huawei,


Categories