I'm learning MySQL and I get this problem:
No suitable driver found for jdbc:mysql//localhost:3306/demo?useSSL=false I have read other solutions but it's not working. This is my code:
package jdbc.test;
import java.sql.*;
public class JdbcInsertDemo {
public static void main(String[] args) throws SQLException {
Connection myConn = null;
Statement myStmt = null;
ResultSet myRs = null;
String dbUrl = "jdbc:mysql//localhost:3306/demo?useSSL=false";
// jdbc:mysql//localhost:3306/demo?useSSL=false
String user = "student";
String pass = "student";
try {
myConn = DriverManager.getConnection("jdbc:mysql//localhost:3306/demo?useSSL=false", user, pass);
myStmt = myConn.createStatement();
System.out.println("Inserting a new employee to database\n");
int rowsAffected = myStmt.executeUpdate("Insert into employees" + "(last_name, first_name, email, department, salary)" + "values" + "('Wright' , 'Eric', 'eric.wright@foo.com', 'HR', 33000.00)");
myRs = myStmt.executeQuery("slect * from employees order by last_name");
while(myRs.next()) {
System.out.println(myRs.getString("last_name") + ", " + myRs.getString("first_name"));
}
}
catch(Exception exc) {
exc.printStackTrace();
}
finally {
if (myRs != null) {
myRs.close();
}
}
}
}