Reputation: 41
I run a web application on tomcat 7. My Web application use connector mysql to connect db. It connect to mysql and query ok. But when I run it for 3 - 4 hours it occur error with get connection and the log I get in tomcat is
"java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/mydb?autoReconnectForPools=true&useUnicode=true&characterEncoding=utf-8 at java.sql.DriverManager.getConnection(DriverManager.java:596) at java.sql.DriverManager.getConnection(DriverManager.java:215)"
Upvotes: 0
Views: 669
Reputation: 426
This is probably a result of Tomcat service provider mechanism memory leaks prevention efforts. A workaround suggested is to register the driver manually in your controller:
@PostConstruct
public void init() {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
}
Upvotes: 0
Reputation: 620
You're missing the jar with the MySQL driver. If it's not under /WEB-INF/lib then drop it in /lib/ext
Upvotes: -1