my dog learned polymorphism*
The moose likes JDBC and the fly likes class.forname Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "class.forname " Watch "class.forname " New topic
Author

class.forname

A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hi,
I wrote the connection class.in that i wrote class.forname()........


etc.

now my question is every time i am calling the above connection class ,
class.forname ()method will execute or only once it will execute.

and what the class.forname() returns.

cheers,
babu.


Thanks,
www.Admakr.in
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

We get this question a lot, a pervious conversation is here.

Can find out what it returns by looking at the API
A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hi,
class.forname returns class object.ok.

i want clarification for class.forname executes as many times as i requested the class or not?

cheers,
babu.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

If the class has not been loaded, the first time Class.forName() is called it will cause the class to load. Loading the class also causes it to be registered wit the DriverManager.

If the Class is already loaded, it get returned from the ClassLoader cache and does not get loaded again. Therefore you can have as many calls to Class.forName() as you like and the overhead will be minimal.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class.forname
 
Similar Threads
How must i "synchronize" my servlets?
problem while accessing class file from a package
After loading many drivers how to use specific?
Search Engine
SQL Exception :general error