Can you say some possible reasons why MySQL would connect to a regular java class, but not to a servlet? Something is not right when I run in tomcat, but as application everything is fine.
Asked
Active
Viewed 32 times
2 Answers
1
not sure if this is the problem but maybe MySQL driver is not packaged with your war.
If you are using Eclipse, you could try to: Right button on your project -> Properties -> Deployment Assembly and Add your mysql driver to it
If you are using maven be sure to add that dependency:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>your driver version</version>
</dependency>
Aside from that, is better to include this driver in your Tomcat libraries folder.
Hope it helps.

OscarBcn
- 626
- 4
- 11
0
One of the reasons was jdbc jar file should have also been in tomcat/lib folder, that was my problem.

Sargsyan Grigor
- 533
- 1
- 5
- 22