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

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  


What type of drivers are used for web application?

2 Answers  


What is statement and resultset in jdbc?

0 Answers  


Why is jdbc needed?

0 Answers  


What are the different types of statements in jdbc?

0 Answers  






What is JDBC ResultSet?

0 Answers  


password, is stored in as plain text. What can I do to protect my passwords?

0 Answers  


What are the differences between statement and preparedstatement interface?

0 Answers  


How do I check in my code whether a maximum limit of database connections have been reached?

0 Answers  


Why we use while rs next ())?

0 Answers  


What is the use of JDBC DriverManager class?

0 Answers  


Explain the difference between rowset vs. Resultset in jdbc?

0 Answers  


Categories