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

What are the advantages of using preparedstatement in java?

0 Answers  


what are the types of result sets in JDBC 3.0 ?

3 Answers   HCL,


What is database deadlock ?

0 Answers  


What are different parts of a url?

0 Answers  


What is the role of jdbc drivermanager class?

0 Answers  






How can you tune SQL statements?

2 Answers   Wipro,


What do you understand by jdbc driver and explain its types?

0 Answers  


What is the exception thrown by JDBC ?

7 Answers  


What are the new features available in jdbc 4.0?

0 Answers  


Is it possible to connect to multiple databases? Using single statement can we update or extract data from two or three or many databases?

0 Answers  


how many JDBC drivers ?name them?

6 Answers   Idea, CTS,


Explain the sequence of steps to connect to the database?

3 Answers   Wipro,






Categories