Here is my code - i am simply checking my MySQL database connection.
But first i have compiled and run the program successfully. but then i have commented the line Class.forName .
Still when i compile it runs successfully, without any error.Why?
import java.sql.Connection;
import java.sql.DriverManager;
public class FirstJbdc {
public static void main(String[] args) {
Connection cn=null;
try {
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded successfully");
cn=DriverManager.getConnection("jdbc:odbc:myDSN","root", "java");
System.out.println("Database connected successfully....");
System.out.println(cn);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}