My goal is to enhance a working set of simple REST services by a service, that returns the result from a SQL query issued by plain JDBC to a MySQL database.
The REST service works fine on Tomcat without accessing the database.
A class works fine as a stand alone app, which accesses the MySQL data base on a remote server. The class provides a get function returning a string.
When I call that function from a REST service to return the string, I get the no suitable driver found error.
The MySQL driver has been deployed by Tomcat on Tomcat/webapps/app/WEB-INF/lib from the war created by the spring-boot framework using Maven. That is why I think Tomcat should be able to find it.
What I tried so far (restarted Tomcat every time):
- Copied the MySQL driver form Tomcat/webapps/app/WEB-INF/lib to Tomcat/lib.
- Filled application.properties with spring.datasource.url, username and password, as directed by SpringBoot documentation.
- Defined the MySQL resource in Tomcat/webapps/app/META-INF/context.xml and the resource-ref in Tomcat/conf/web.xml.
Still getting the "no suitable driver found" error.
Versions: Win-10, Java-11, Maven 3.8.4, Tomcat-10. For the spring-boot-starter-web and -tomcat dependencies and the spring-boot-maven-plugin, there are no version numbers in the pom.xml.
Should it work that way (sure, I searched for typos and syntax failures)?
Or did I miss something for Tomcat to reach the MySQL database?