This question already has an answer here:
The infamous java.sql.SQLException: No suitable driver found
java.sql.SQLException: No suitable driver found
This exception can have 2 causes:
Since the driver seems to be loaded (although in an incorrect manner), it look like that the URL is plain wrong. Ensure that the value of your
url variable matches the following format
Unrelated to the concrete problem: Java code doesn't belong in a JSP file. Work on that as well. Your exception handling is also terrible, you should throw the exception (so that it blocks executing the remnant of the code) instead of printing the message/trace and then continue with the code.
Did you register your class with the Driver? For example:
I had to remove mysql-connector-java-*.jar from WEB-INF/lib and add it into tomcat6/lib folder. (tomcat6 is where tomcat was installed.) I do not know why this worked but it worked for me.
Are you passing an emtpy url string to getConnection()? The error message starts out
No suitable driver found for ERROR
No suitable driver found for [blank]? Seems like you're not passing a url here.
Go to library folder of your project and right click it,then go to 'Add Library' option.Now add the mysql.jdbc.Driver