The document mentioned in the following link says:

When using the sqljdbc4.jar class library, applications do not need to explicitly register or load the driver by using the Class.forName method. When the getConnection method of the DriverManager class is called, an appropriate driver is located from the set of registered JDBC drivers. For more information, see Using the JDBC Driver.

Link: Working with a Connection


The why do I get the following error when I remove the following line from my code?

Java Code:
`Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");`



Error while catching the following exception. My catch block and error are as follows:


Java Code:
     catch(SQLException ex2){
                                                                                                            System.out.println("Stacktrace Below:");
                 ex2.printStackTrace();
                 System.out.println("Error Trace in Connection : " + ex2.getMessage());
                            } 

    Stacktrace Below:
    	
    Error Trace in Connection : No suitable driver found for jdbc:sqlserver://xx.xx.x.xxx:1433;database*​Name=MyDatabase
    java.sql.SQLException: No suitable driver found for jdbc:sqlserver://xx.xx.x.xxx:1433;database*​Name=MyDatabase
    	at java.sql.DriverManager.getConnection(DriverManager.java:596)
    	at java.sql.DriverManager.getConnection(DriverManager.java:215)
    	at ebmextractor.MyClass.call(MyClass.java:432)
    	at ebmextractor.MyClass.call(MyClass.java:26)
    	at javafx.concurrent.Task$TaskCallable.call(Task.java:1259)

I have the `sqljdbc4.jar` file in my Netbeans library as follows:




1) Do I need to specify any class path in Netbeans?

2) Should the `sqljdbc4.jar` be inside the same folder like other jar files?


Not using Class.forName as per documentation is producing error-jar.jpg