0

I'm using putty to write a Java program that takes in SQL, but I'm getting this error:

No suitable driver found for jdbc:mysql://localhost:3306/Chinook

I'm not sure what's going wrong.
Here is my code:

import java.sql.*;
import java.io.IOException;
public class Q1{
        public static void main (String args[]) throws IOException {
                Connection conn=null;
                String driver="com.mysql.jdbc.Driver";
                String url="jdbc:mysql://localhost:3306/Chinook";
                System.setProperty(driver,"");
                try{
                        conn = DriverManager.getConnection(url,"username","password");
                        System.out.println("Connected to the DB");
                        }
                        catch (SQLException ex){
                                System.out.println("SQLException:"+ ex.getMessage());
                        }
                }
}
ProgramFOX
  • 6,131
  • 11
  • 45
  • 51

1 Answers1

0

This line is pretty much self explanatory
: No suitable driver found for jdbc:mysql://localhost:3306/Chinook

You need to download a .jar file for jdbc i.e. jdbc.jar from HERE and then add it to your claspath ( project )

Also another thing is that you have jdbc driver but it could be the case that you are trying to access mysql withouth appropriate db for that type of database

Maciej Cygan
  • 5,351
  • 5
  • 38
  • 72