Possible Duplicate:
java.sql.SQLException: No suitable driver found for localhost test
I am trying to make my first connection to a database using Java language. Here is the code that I have so far:
import java.sql.*;
public class Database {
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql:mud", "myusername", "mypassword");
Statement stmt = con.createStatement();
}
}
I also added MySQL connector .jar to JRE/lib/ex. I try to run the program with "java Database". I get this error:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:mysql:mud
at java.sql.DriverManager.getConnection(DriverManager.java:640)
at java.sql.DriverManager.getConnection(DriverManager.java:200)
at Database.main(Database.java:8)
I would appreciate any help. Thanks.