I placed mysql driver jar file in the WEB-INF/lib but it did not work and I could not get the connection till I placed the file manually in the system classpath. Here is the code and web.xml config I used. Do I need to do anything else as well apart from doing things below. Also I do not think any import is required when using FQ class name of the driver. Please help.
Class.forName(getServletConfig().getServletContext().getInitParameter("dbDriver")); Connection con = DriverManager.getConnection(getServletConfig().getServletContext().getInitParameter("dbURL"), "raghu","raghu123");
Indeed, it should be working, Chris is right. If you put your .jar file in your Tomcat/lib folder, it will work not only for this particular application, but also for all the other applications you may have. But yet, this is a workaround, it should be working if you put the .jar file in the WEB-INF/lib folder of your application. Well, try unistalling your Tomcat (you're using Tomcat, right?) and installing it again... it might work...
raghu, are you using an IDE like Eclipse and running your Tomcat instance inside of the IDE? If so, that would explain the problem. In Eclipse, you'd have to right-click the jars under WEB-INF/lib and select the option for adding them to your Build Path.
A good workman is known by his tools.
Joined: Jul 05, 2007
I am not using eclipse as of now. Just manual coding. I will try Bob's recipe and revert soon.