java.sql.SQLException: No suitable driver found for jdbc:mysql/localhost:3306/java



  • package conexion;
    
    import com.mysql.jdbc.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    
    
    public class conexion {
        Connection co;  
        Statement stm;
    
        //jdbc:mysql://localhost:3306/java?zeroDateTimeBehavior=convertToNull [root on Default schema]
    
        public static Connection iniciarConnection(){   
            try {
    
                Class.forName("com.mysql.jdbc.Driver"); 
                Connection co= DriverManager.getConnection("jdbc:mysql//localhost:3306/java", "root", "");
                Statement stm = co.createStatement();
                System.out.println("Conectado correctamente a la Base de Datos");
                return co;
            } catch (ClassNotFoundException e) {
                System.out.println("Clase no encontrada: "+e);
            } catch (SQLException e) {
                System.out.println("Error de conexion: "+e);
            } catch (Exception e) {
                System.out.println("Error desconocido: "+e);
            }
                return null;
        }
    }
    

    Here's the OutPut:

    Connection Error: java.sql.SQLException: No suitable driver found for

    jdbc:mysql/localhost:3306/java



  • Try adding " later of jdbc:mysql, like this:

    Connection co= DriverManager.getConnection("jdbc:mysql://localhost:3306/java", "root", "");
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2