Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

522
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda