Not long time ago, I was doing some Java SE programming. To make use of JDBC, I would simply put driver in project's build path. And that is how everything worked.
But then I started studying about Servlets & JSPs. Instead of Java project, now I had Dynamic Web Project. I did the same work (put driver inside project's build path) and hoped everything would work. Unfortunately, it didn't.
I found out here that I need to register my driver using Class.forName() method.
My questions looks rather simple => Why I need to register driver for Dynamic Web Project, but not for Java Project?
Class.forName() was a mechanism to force loading of database drivers. It has been obsolete for a very long time now, but people keep replicating it.
A webapp should NOT be using a DriverManager It should be using a Database Connection Pool. Connection Pools define the database context (including the driver) to the webapp server, and that knowledge is not required by the webapp itself.
Loudly announcing something is true and finding out you're wrong makes you feel foolish.
Finding out you're wrong and refusing to admit it makes you LOOK foolish.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop