Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

523
Visualizações
SQLException: No suitable driver found for jdbc:mysql. SQLState: 08001. VendorError: 0

I know here are lot of questions here on this topic. I tried all solutions but still can't get connection to data base. Please help! I am working on web app. NetBeans, Tomcat 9, MySQL.

Error:

SQLException: No suitable driver found for jdbc:mysql://localhost:3306user=webstudent&password=webstudent
SQLState: 08001
VendorError: 0
java.lang.NullPointerException: Cannot invoke "java.sql.Connection.prepareStatement(String)" because "con" is null

My files in project:

Context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/LibraryWebApp"/>

DB.java:

package dao;
import java.sql.*;

//Database connection method
public class DB {
    public static Connection getCon() throws ClassNotFoundException{
    Connection con=null;
    try {
            con=DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306"+
                                   "user=webstudent&password=webstudent");
            Class.forName("com.mysql.jdbc.Driver");   
    } catch(SQLException ex){
            System.out.println("SQLException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
            System.out.println("VendorError: " + ex.getErrorCode());
        }
    return con;
}     
}

See imported libraries in the project.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

SQLException: No suitable driver found for jdbc:mysql://localhost:3306user=webstudent&password=webstudent

Your connection string is incorrect. You've missed the database name. So, update the database name in the following string and use it.

jdbc:mysql://localhost:3306/database_name?user=webstudent&password=webstudent

Also, place the following statement prior to connection stmt

Class.forName("com.mysql.jdbc.Driver"); 

Updated:

Add the serverTimezone explicitly in the connection string Eg:

jdbc:mysql://localhost:3306/database_name?user=webstudent&password=webstudent&serverTimezone=UTC
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda