I have a simple code that needs to connect to a mysql DB and execute a query.
try {
conn =
DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=1234");
Statement stm = conn.createStatement();
stm.executeQuery(query);
return true;
This code works like a charm in a test project with only a class with void main. But in my project that is a web application, I'm using apache tomcat and the same code displays the error:
SQLException: No suitable driver found for jdbc:mysql://localhost/test?user=root&password=1234
I've added the jar, the classpath the everything. Is there something special that I need to do because I'm using tomcat? Thanks, Dragos