java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver

  • Comments 33

If you are seeing this exception while trying to use the SQL Server 2005 JDBC driver, then you will need to update the application.

The class name has changed between the SQL Server 2000 JDBC driver and the SQL Server 2005 JDBC driver.  This particular class "com.microsoft.jdbc.sqlserver.SQLServerDriver" is the class name for the SQL Server 2000 JDBC driver.  The SQL Server 2005 JDBC driver class name is "com.microsoft.sqlserver.jdbc.SQLServerDriver".
Note the change: from "microsoft.jdbc.sqlserver" to "microsoft.sqlserver.jdbc"

In addition, the SQL Server 2005 JDBC driver has a different URL prefix from the SQL Server 2000 JDBC driver.  The SQL Server 2000 JDBC driver uses an URL prefix of "jdbc:microsoft:sqlserver://", while the SQL Server 2005 JDBC driver uses an URL prefix of "jdbc:sqlserver://".
Note the removal of "microsoft" from the URL prefix.

For additional information on all the different Connection string properties, please refer to the following MSDN topic: http://msdn2.microsoft.com/en-us/library/ms378428(SQL.90).aspx

Jimmy Wu, SQL Server
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights

Leave a Comment
  • Please add 7 and 4 and type the answer here:
  • Post
  • Why on earth would you change this?  Some of us have deadlines to hit and when this issue occurs in a 3rd party library it has very real impact.

  • sir im using eclipse indigo IDE, while i try to connect with the database, it throws an exception like "java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver". i already added sqljdbc4-2.0 jar in the external libraries.but im getting trouble. Any one please help me

  • Hello everybody,

    I resolved this issue this way:

    I'm trying to connect to SQL Server 2008 R2.

    I'm using Eclipse and JDK 1.7.0_65.

    CLASSPATH definition - C:\Program Files (x86)\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\sqljdbc4.jar

    Driver - Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

    Connection string - jdbc:sqlserver://your_iserver_ip:1433;DatabaseName=Test

    After defining all mentioned above you need to copy sqljdbc4.jar file to your project folder and then to import the jar file into eclipse.

    Instructions for jar import into Eclipse:

    Right click on your project > Properties > Java build path > Add external JARs button >  choose relevant jar file.

    Good luck!

Page 3 of 3 (33 items) 123