Tag Archives: driver

Solution to SQLException: No suitable driver found for jdbc:mysql

Just a quick fix.

Instead of:

Connection con = null;
 
String url = "jdbc:mysql://localhost:3306/mysql";
String user = "user";
String password = "password";
con = DriverManager.getConnection(url, user, password);

You should have:

Connection con = null;
 
String url = "jdbc:mysql://localhost:3306/mysql";
String user = "user";
String password = "password";
 
try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
    System.err.println(ex.getMessage());
}
con = DriverManager.getConnection(url, user, password);

Continue reading

No suitable driver found for jdbc:mysql

Miałem dzisiaj bardzo dziwny problem z NetBeans7.2 z próbą stworzenia połączenia z bazą danych MySQL.

Zaczęło się od niedoczytanej dokumentacji… czyli zamiast:

            Connection con = null;
 
            String url = "jdbc:mysql://localhost:3306/mysql";
            String user = "user";
            String password = "password";
            con = DriverManager.getConnection(url, user, password);

Continue reading