If I want to connect to a mysql database from servlet, I need to load the driver for mysql using Class.forName(mysql driver)
Where do I need to keep this MySQL driver in eckipse IDE ? I mean in order to load this driver, I have to keep it at some default location so that forName() can load it. So whats this default location ? Can I also provide a complete path to the driver location ?
For a servlet, you do not need to have the driver in Eclipse anywhere. Instead, you should place the driver in the proper location for your app server. If the app server allows you to place the driver JAR in your WAR, then add the driver in the Libraries tab of the Java Build Path of your project's properties. If you let us know which app server, we can be more specific.
I dont understand. If I am connecting to MySQL from servlet, how will the connection be made to database without driver ?
I am not using any app server, I am creating servlet only for practice purpose. Anyways later on I plan to use WebSphere.
1) If I dont have MySQL driver will the driver still be loaded ? Does Eclipse come with database drivers preloaded ? If not, then from where does a driver get loaded to make connection ?
2) If I have MySQL driver stored in any directory on my computer, will it be automatically located and loaded in server ?
3) Do I need to store driver in a particular location only ? if yes, where ?
Please answer these questions pointwise and it will help remove confusion and make picture clear.