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 4 and 4 and type the answer here:
  • Post
  • Hi..

    Please tell me how to download and install SQL Server 2005 JDBC driver

  • Hi Deepak,

    Please refer to http://msdn.microsoft.com/data/jdbc

    for download links of the SQL Server 2005 JDBC driver.  The installation information for both Windows and Unix platforms are in the download page.

    Jimmy

  • D:\Elina>appletviewer Demo22.html

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

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:167)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

           at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:118)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

           at java.lang.Class.forName0(Native Method)

           at java.lang.Class.forName(Class.java:164)

           at Demo22.paint(Demo22.java:38)

           at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

           at sun.awt.RepaintArea.paint(RepaintArea.java:224)

           at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)

           at java.awt.Component.dispatchEventImpl(Component.java:4031)

           at java.awt.Container.dispatchEventImpl(Container.java:2024)

           at java.awt.Component.dispatchEvent(Component.java:3803)

           at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

           at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh

    read.java:234)

           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre

    ad.java:163)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

           at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    Caused by: java.io.FileNotFoundException: D:\Elina\com\microsoft\jdbc\sqlserver\

    SQLServerDriver.class (The system cannot find the path specified)

           at java.io.FileInputStream.open(Native Method)

           at java.io.FileInputStream.<init>(FileInputStream.java:106)

           at java.io.FileInputStream.<init>(FileInputStream.java:66)

           at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection

    .java:70)

           at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon

    nection.java:161)

           at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:279)

           at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)

           at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:157)

           at java.security.AccessController.doPrivileged(Native Method)

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:154)

           ... 19 more

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

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:167)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

           at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:118)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

           at java.lang.Class.forName0(Native Method)

           at java.lang.Class.forName(Class.java:164)

           at Demo22.paint(Demo22.java:38)

           at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

           at sun.awt.RepaintArea.paint(RepaintArea.java:224)

           at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)

           at java.awt.Component.dispatchEventImpl(Component.java:4031)

           at java.awt.Container.dispatchEventImpl(Container.java:2024)

           at java.awt.Component.dispatchEvent(Component.java:3803)

           at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

           at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh

    read.java:234)

           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre

    ad.java:163)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

           at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    Caused by: java.io.FileNotFoundException: D:\Elina\com\microsoft\jdbc\sqlserver\

    SQLServerDriver.class (The system cannot find the path specified)

           at java.io.FileInputStream.open(Native Method)

           at java.io.FileInputStream.<init>(FileInputStream.java:106)

           at java.io.FileInputStream.<init>(FileInputStream.java:66)

           at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection

    .java:70)

           at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon

    nection.java:161)

           at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:279)

           at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)

           at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:157)

           at java.security.AccessController.doPrivileged(Native Method)

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:154)

           ... 19 more

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

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:167)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

           at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:118)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

           at java.lang.Class.forName0(Native Method)

           at java.lang.Class.forName(Class.java:164)

           at Demo22.paint(Demo22.java:38)

           at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

           at sun.awt.RepaintArea.paint(RepaintArea.java:224)

           at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)

           at java.awt.Component.dispatchEventImpl(Component.java:4031)

           at java.awt.Container.dispatchEventImpl(Container.java:2024)

           at java.awt.Component.dispatchEvent(Component.java:3803)

           at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

           at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh

    read.java:234)

           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre

    ad.java:163)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

           at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    Caused by: java.io.FileNotFoundException: D:\Elina\com\microsoft\jdbc\sqlserver\

    SQLServerDriver.class (The system cannot find the path specified)

           at java.io.FileInputStream.open(Native Method)

           at java.io.FileInputStream.<init>(FileInputStream.java:106)

           at java.io.FileInputStream.<init>(FileInputStream.java:66)

           at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection

    .java:70)

           at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon

    nection.java:161)

           at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:279)

           at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)

           at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:157)

           at java.security.AccessController.doPrivileged(Native Method)

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:154)

           ... 19 more

    plz help

  • i have set all class apth all things are right , i am using sql server 2000 and windows 2003 allready i downloaded JBDC Driver for sql server 2000 but why i am getting this error plz help me

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

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:167)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

           at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:118)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

           at java.lang.Class.forName0(Native Method)

           at java.lang.Class.forName(Class.java:164)

           at Demo22.paint(Demo22.java:38)

           at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

           at sun.awt.RepaintArea.paint(RepaintArea.java:224)

           at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)

           at java.awt.Component.dispatchEventImpl(Component.java:4031)

           at java.awt.Container.dispatchEventImpl(Container.java:2024)

           at java.awt.Component.dispatchEvent(Component.java:3803)

           at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

           at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh

    read.java:234)

           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre

    ad.java:163)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

           at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    Caused by: java.io.FileNotFoundException: D:\Elina\com\microsoft\jdbc\sqlserver\

    SQLServerDriver.class (The system cannot find the path specified)

           at java.io.FileInputStream.open(Native Method)

           at java.io.FileInputStream.<init>(FileInputStream.java:106)

           at java.io.FileInputStream.<init>(FileInputStream.java:66)

           at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection

    .java:70)

           at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon

    nection.java:161)

           at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:279)

           at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)

           at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:157)

           at java.security.AccessController.doPrivileged(Native Method)

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:154)

           ... 19 more

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

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:167)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

           at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:118)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

           at java.lang.Class.forName0(Native Method)

           at java.lang.Class.forName(Class.java:164)

           at Demo22.paint(Demo22.java:38)

           at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

           at sun.awt.RepaintArea.paint(RepaintArea.java:224)

           at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)

           at java.awt.Component.dispatchEventImpl(Component.java:4031)

           at java.awt.Container.dispatchEventImpl(Container.java:2024)

           at java.awt.Component.dispatchEvent(Component.java:3803)

           at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

           at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh

    read.java:234)

           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre

    ad.java:163)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

           at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    Caused by: java.io.FileNotFoundException: D:\Elina\com\microsoft\jdbc\sqlserver\

    SQLServerDriver.class (The system cannot find the path specified)

           at java.io.FileInputStream.open(Native Method)

           at java.io.FileInputStream.<init>(FileInputStream.java:106)

           at java.io.FileInputStream.<init>(FileInputStream.java:66)

           at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection

    .java:70)

           at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon

    nection.java:161)

           at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:279)

           at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)

           at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:157)

           at java.security.AccessController.doPrivileged(Native Method)

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:154)

           ... 19 more

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

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:167)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

           at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:118)

           at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

           at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

           at java.lang.Class.forName0(Native Method)

           at java.lang.Class.forName(Class.java:164)

           at Demo22.paint(Demo22.java:38)

           at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

           at sun.awt.RepaintArea.paint(RepaintArea.java:224)

           at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)

           at java.awt.Component.dispatchEventImpl(Component.java:4031)

           at java.awt.Container.dispatchEventImpl(Container.java:2024)

           at java.awt.Component.dispatchEvent(Component.java:3803)

           at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

           at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh

    read.java:234)

           at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre

    ad.java:163)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

           at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

           at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    Caused by: java.io.FileNotFoundException: D:\Elina\com\microsoft\jdbc\sqlserver\

    SQLServerDriver.class (The system cannot find the path specified)

           at java.io.FileInputStream.open(Native Method)

           at java.io.FileInputStream.<init>(FileInputStream.java:106)

           at java.io.FileInputStream.<init>(FileInputStream.java:66)

           at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection

    .java:70)

           at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLCon

    nection.java:161)

           at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:279)

           at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)

           at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:157)

           at java.security.AccessController.doPrivileged(Native Method)

           at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:154)

           ... 19 more

  • Hi Elina,

    This type of questions that require back and forth troubleshooting are probably best suited for the newsgroup or forum.  The JDBC newsgroup can be found at http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.jdbcdriver and the JDBC forum can be found at http://forums.microsoft.com/msdn/showforum.aspx?forumid=87&siteid=1

    Looking at the call stack I noticed there is a file not found exception

    "Caused by: java.io.FileNotFoundException: D:\Elina\com\microsoft\jdbc\sqlserver\SQLServerDriver.class (The system cannot find the path specified)"

    You mentioned that you have all the classpath set correctly.  If you can post this question on either the newsgroup or forum with additional app configuration, the Java environment settings, and the class name you are using, there will be a broader set of people in the community to help answer your question.

    Jimmy

  • Hello friends,

    I had tried to connect the SQL Server 2000 Data Base using the JDBC.

    My Programming code is

    import java.*;

    public class Connect{

        private java.sql.Connection  con = null;

        private final String url = "jdbc:microsoft:sqlserver://";

        private final String serverName= "localhost";

        private final String portNumber = "1433";

        private final String databaseName= "pubs";

        private final String userName = "user";

        private final String password = "password";

        // Informs the driver to use server a side-cursor,

        // which permits more than one active statement

        // on a connection.

        private final String selectMethod = "cursor";

        // Constructor

        public Connect(){}

        private String getConnectionUrl(){

             return url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";";

        }

        private java.sql.Connection getConnection(){

             try{

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

                  con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password);

                  if(con!=null) System.out.println("Connection Successful!");

             }catch(Exception e){

                  e.printStackTrace();

                  System.out.println("Error Trace in getConnection() : " + e.getMessage());

            }

             return con;

         }

        /*

             Display the driver properties, database details

        */

        public void displayDbProperties(){

             java.sql.DatabaseMetaData dm = null;

             java.sql.ResultSet rs = null;

             try{

                  con= this.getConnection();

                  if(con!=null){

                       dm = con.getMetaData();

                       System.out.println("Driver Information");

                       System.out.println("\tDriver Name: "+ dm.getDriverName());

                       System.out.println("\tDriver Version: "+ dm.getDriverVersion ());

                       System.out.println("\nDatabase Information ");

                       System.out.println("\tDatabase Name: "+ dm.getDatabaseProductName());

                       System.out.println("\tDatabase Version: "+ dm.getDatabaseProductVersion());

                       System.out.println("Avalilable Catalogs ");

                       rs = dm.getCatalogs();

                       while(rs.next()){

                            System.out.println("\tcatalog: "+ rs.getString(1));

                       }

                       rs.close();

                       rs = null;

                       closeConnection();

                  }else System.out.println("Error: No active Connection");

             }catch(Exception e){

                  e.printStackTrace();

             }

             dm=null;

        }    

        private void closeConnection(){

             try{

                  if(con!=null)

                       con.close();

                  con=null;

             }catch(Exception e){

                  e.printStackTrace();

             }

        }

        public static void main(String[] args) throws Exception

          {

             Connect myDbTest = new Connect();

             myDbTest.displayDbProperties();

          }

    }

    When I was run this program it is displaying as

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

    at java.net.URLClassLoader$1.run(Unknown Source)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    at java.lang.Class.forName0(Native Method)

    at java.lang.Class.forName(Unknown Source)

    at Connect.getConnection(Connect.java:24)

    at Connect.displayDbProperties(Connect.java:42)

    at Connect.main(Connect.java:78)

    Error Trace in getConnection() : com.microsoft.jdbc.sqlserver.SQLServerDriver

    Error: No active Connection

    Plese help me any one knows where i did a mistake.

    My Email-Id is rajeshlab@yahoo.com

  • Are you trying to use the SQL2005 driver then your url is wrong the right URL is

    com.microsoft.sqlserver.jdbc.SQLServerDriver

  • Hi,

    I have tried to use the SQL Server JDBC Driver for SQL 2005. I keep getting "java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver" . I have added "sqljdbc.jar" to mu PATH variable but still the error persists

  • Hi Amarnath,

    Can you confirm that you are specifying the full path to the sqljdbc.jar file in the JAVA classpath when starting the application?  Or, are you specifying the directory where sqljdbc.jar exists in the system environment PATH?

    example:

     java -cp .;c:\MSJDBC\sqljdbc_1.2\enu\sqljdbc.jar ...

    HTH,

    Jimmy Wu

  • i can't create connection using SQL server 2005 using java.

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

    I am getting this exception,please help me to resolve this,added sqljdbc4.jar in the class path.

  • What is your Java version. How are you invoking your app.

  • How to connect sql server 2008, always throw this exception! Thanks very much!

  • kumon,

    Please provide a more specific error message and more information regarding your scenario back here in the blog or to this forum:

    http://social.msdn.microsoft.com/forums/en-US/sqldataaccess/threads/

    --Tres London [SQL Server]

  • I am using eclipse and I have added both sqljdbc4.jar and sqljdbc.jar in classpath. Still I am getting

    ClassNotFoundException:

    com.microsoft.jdbc.sqlserver.SQLServerDriver

    SQLException:No suitable driver found for jdbc:sqlserver://localhost:1433;databaseName=analyticsdbuser=sa;password=XXXXX

Page 1 of 3 (33 items) 123