Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the driver

 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have always used a statement like

to get the JDBC driver.

Why don't we just import it with an import statement?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. That was helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic