Error in Netbeans java.sql.SQLException: No suitable driver found for jdbc: mysql: // localhost: 3306 / patterns [duplicate]

0

Good I am having a problem with this program that I did it gives me this error and I have tried everything but nothing works, I am connected to the database but it does not work. Here the code:

package conectaBD;
import java.sql.*;

public class NewClass {
public static void main(String args []){
       try{

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


      Statement MyStatement= MyConnection.createStatement();


      ResultSet MyResultSet = MyStatement.executeQuery("SELECT * FROM usuario2");


      while(MyResultSet.next()){
          System.out.println(MyResultSet.getString("id")+ " " 
          + MyResultSet.getString("nombre") + " ");
      }

      }catch(Exception e){

          System.out.println("NO CONECTA!!");
          e.printStackT**texto en negrita**race(); 
     }
  }
}
    
asked by Agustin Lyon 12.10.2018 в 20:07
source

1 answer

0

Have you added the MySQL JDBC Driver library?

    
answered by 12.10.2018 в 20:35