Hello, my code is

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class LoadDriver {
    public static void main(String[] args) {
		Connection conn = null;
		try {
            // The newInstance() call is a work around for some
            // broken Java implementations

        } catch (Exception ex) {
            // handle the error

        try {
			conn =  DriverManager.getConnection("jdbc:mysql:rootkit", "root", "1231");

    // Do something with the Connection
		catch (SQLException ex) {
    // handle any errors
		System.out.println("SQLException: " + ex.getMessage());
		System.out.println("SQLState: " + ex.getSQLState());
		System.out.println("VendorError: " + ex.getErrorCode());


the compilation is ok but when i try to run it, it displays:

C:\Users\0717857\Desktop\JDBC>java -classpath . LoadDriver
SQLException: No suitable driver found for jdbc:mysql:rootkit
SQLState: 08001
VendorError: 0

This means that the line "Class.forName("com.mysql.jdbc.Driver").newInstance();" is not working.any idea for why this happens? thank you

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

6 Years
Discussion Span
Last Post by masijade

Thanks for the reply, i'll surely read it after this. however, i think the driver is not even loaded since it display the "daaaaaaaaaa" which is in the Exception and this means that the "Class.forName("com.mysql.jdbc.Driver").newInstance();" is not working, isn't it?


No. That would be a ClassNotFoundException. You are getting a NoSuitableDriver, which means it does not recognise that URL as a MySQL URL and so does not know to use the loaded MySQL driver, so it can only complain that it doesn't have any driver that will work with that URL.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.