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
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
System.out.println("daaaaaaaaaa");
// 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
daaaaaaaaaa
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