What is class in class.forname()?

Showing Answers 1 - 7 of 7 Answers

Gupta

  • Jan 2nd, 2006
 

Class.forName method searches for the class specified in the method and returns the Class object

  Was this answer useful?  Yes

sathis kumar J

  • Jan 17th, 2006
 

Class.forName eagerly loads the class if it not already loaded. Inside the JVM there is a HashMap of all the classes that have been previously loaded. So Class. forName takes under a millisecond if the class you have want is already loaded, If not, it might take 15 milliseconds or so to load it.

  Was this answer useful?  Yes

Ashish Gupta

  • Jan 31st, 2006
 

It is defined in java.lang package. And can be used to load driver or native code. For instance the following line is used to load and register the oracle thin dirver in the DriverManager class:

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

for Oracle8i thin jdbc driver.

Ashish Gupta

  Was this answer useful?  Yes

pushpesh.kumar@sun.com

  • Apr 12th, 2006
 

Hi,

   Class is the class in class.forName(). The forName method will return the object of the class that we are passing as string. But the compiler will the string that we have passed to this method only at runtime and if the class that we have passed is not found in the classpath then runtime exception called class not found will occur.

  Thanks and Regards

  Was this answer useful?  Yes

Gandharv

  • May 2nd, 2006
 

Class is the name of class in Class.forName().

  Was this answer useful?  Yes

Jayant Dhargawe

  • Jun 6th, 2006
 

Hi,

Class is also class in java.lang package, it has a method getName(String arg) which take Driver Class u have supply libery in classpath lib directory. Its search given argrument and loading particular class into JVM. and use further process for getting connection from database.

  Was this answer useful?  Yes

siva kumar reddy

  • Aug 7th, 2006
 

hi ,

Class.forName("srting");

when ever execute the above statement first chesks that class is loaded before or not .if not loaded it loads the class.

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

In this case driver manager loads the all drivers in the class.

cheers

sivaa

  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