No suitable driver found for jdbc Sqlstate: 08001 Vendorerror: 0

Asked

Viewed 315 times

0

    public static void main(String[] args){

     private String DRIVER = "com.mysql.jdbc.Driver";

     Connection con= null;

        try {
            con = DriverManager.getConnection("jdbc::mysql://localhost:3306/sampledb?useSSL=false","root","");

        } catch(SQLException ex){
            System.out.println("SQLException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
            System.out.println("VendorError: " + ex.getErrorCode());

        }

I am trying to run this method to make a connection with Mysql database and at run time I am having the following error :

Sqlexception: No suitable driver found for jdbc::mysql:/localhost:3306/sampledb? useSSL=false Sqlstate: 08001 Vendorerror: 0

I tried to change my Connection String and could not make it work, tried to change Referenced Libraries(connection drive) and also did not succeed.

I know little of Java and I’ve taken some classes of connection and I came to the same error, which may be occurring?

1 answer

0

It can be one of the following steps:

  1. Are you running the filename project.jar? If so, you may have moved the filename project.jar from the /dist folder. 2.If you are running your project within the IDE, you may not have imported the driver into the project.
  • I indicated where is my connection driver in the question description

  • Right, because try the following solution: Within your project create a package called libs (or as you prefer) and by file explorer move the driver into that package, then you import again. BEFORE THIS PROCESS REMOVE THE DRIVER YOU POINTED OUT.

  • Dude, I can pull out and add the drive. Now, move it impossible

  • Do the following, first REMOVE A THE DRIVER YOU POINTED, then download the driver at this link -> http://geverson.000webhostapp.com/view/projeto/uploads/mysql-connector-java-5.1.48.jar, then create the package within your project then copy or move the downloaded driver into the package you created, and finally add the downloaded driver and copied/moved into your project.

  • I was able to fix it. Missing connection Class.forName("com.mysql.Cj.jdbc.Driver");

  • blz then, until next.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.