Apostille caelum fj21 error driver mysql

1

Good afternoon guys,

Beginning I'm studying the caelum Java WEB booklet but the following error is showing up. I already imported the MySQL driver, I switched between the commented line and commented the above, but it is not working the browser error is

  

HTTP Status 500 - java.sql.SQLException: No suitable driver found for jdbc: mysql: // localhost / fj21

package br.com.caelum.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;

//class conexão com o banco de dados
public class ConnectionFactory {

    public Connection getConnection(){
        try {
            Class.forName("com.mysql.jdbc.Driver");
            //DriverManager.registerDriver(new com.mysql.jdbc.Driver());
            return DriverManager.getConnection("jdbc:mysql://localhost/fj21", "root", "822674");
        } catch (Exception e) {
            throw new RuntimeException(e);

        }
    }
}

Stack trace:

GRAVE: Servlet.service() for servlet [br.com.caelum.servlet.AdicionaContatoServlet] in context with path [/fj21-agenda] threw exception
java.lang.RuntimeException: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/fj21
    at br.com.caelum.jdbc.ConnectionFactory.getConnection(ConnectionFactory.java:15)
    at br.com.caelum.dao.ContatoDao.<init>(ContatoDao.java:23)
    at br.com.caelum.servlet.AdicionaContatoServlet.service(AdicionaContatoServlet.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/fj21
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at br.com.caelum.jdbc.ConnectionFactory.getConnection(ConnectionFactory.java:13)
    ... 24 more
    
asked by anonymous 18.01.2016 / 17:56

0 answers