JDBC JAVA No suitable driver found for jdbc:mysql://localhost:3306/voting
I'm trying to connect to a MySQL database using JDBC my code is below. I get an error:
No suitable driver found.
Searching around I found that the usual error is syntax or missing the jar file from the class path. I tried both of these solutions and don't know what to do next it wont connect. Also to manage the databases I have WAMP and MySQL workbench installed not sure if its related.
package test.jdbc;
import java.sql.*;
public class jdbctester {
public static void main(String[] args) {
try {
Connection myconn=DriverManager.getConnection("jdbc:mysql://localhost:3306/voting","root","Vanquish123");
Statement myStmt=myconn.createStatement();
ResultSet myRs=myStmt.executeQuery("select * from electoral");
/*
while(myRs.next()) {
System.out.println(myRs.getString("state")+","+myRs.getString("perDem"));
}
*/
}
catch(Exception exc){
exc.printStackTrace();
}
}
}