aspose file tools*
The moose likes JDBC and the fly likes How to get the driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to get the driver" Watch "How to get the driver" New topic
Author

How to get the driver

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
I have always used a statement like

to get the JDBC driver.

Why don't we just import it with an import statement?


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

An import statement merely makes a class available to the compilation unit at compile time. The Class.forName() causes the class loader to physically find the class and load it into the JVM at run-time (where the driver manager will find and hook up to it).
[ April 13, 2004: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Marilyn de Queiroz:
I have always used a statement like

to get the JDBC driver.

Why don't we just import it with an import statement?

Have a read of this. It's designed to allow flexibility for interchanging drivers, but you could use the import if you wanted to and skip all the classloader stuff.
Jamie
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Thank you. That was helpful.
 
 
subject: How to get the driver