Share via


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

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: https://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

Comments

  • Anonymous
    June 28, 2007
    Hi.. Please tell me how to download and install SQL Server 2005 JDBC driver

  • Anonymous
    June 28, 2007
    The comment has been removed

  • Anonymous
    December 10, 2007
    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:Elinacommicrosoftjdbcsqlserver 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:Elinacommicrosoftjdbcsqlserver 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:Elinacommicrosoftjdbcsqlserver 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

  • Anonymous
    December 10, 2007
    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:Elinacommicrosoftjdbcsqlserver 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:Elinacommicrosoftjdbcsqlserver 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:Elinacommicrosoftjdbcsqlserver 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

  • Anonymous
    December 12, 2007
    The comment has been removed

  • Anonymous
    March 03, 2008
    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

  • Anonymous
    March 04, 2008
    Are you trying to use the SQL2005 driver then your url is wrong the right URL is com.microsoft.sqlserver.jdbc.SQLServerDriver

  • Anonymous
    June 23, 2008
    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

  • Anonymous
    June 25, 2008
    The comment has been removed

  • Anonymous
    February 28, 2009
    i can't create connection using SQL server 2005 using java.

  • Anonymous
    May 12, 2009
    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.

  • Anonymous
    May 13, 2009
    What is your Java version. How are you invoking your app.

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

  • Anonymous
    July 15, 2009
    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]

  • Anonymous
    September 14, 2009
    The comment has been removed

  • Anonymous
    September 15, 2009
    Eclipse sometime uses its  own JVM. I would try adding the appropriate jar (e.g. jdbc4.jar if you are using 1.6 VM) in the libaries of the eclipse project you are working on. The eclipse reference should show you how to add a library for your proejct.

  • Anonymous
    September 18, 2009
    manage to get the codes to work in eclipse! :) 2 parts of the codes needs changes...the following needs to be changed from: 1: private final String url = "jdbc:microsoft:sqlserver://"; to    private final String url = "jdbc:sqlserver://"; AND 2: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); to Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); good luck! :)

  • Anonymous
    November 04, 2009
    While connecting to remote database i'm getting this exception..

  • Anonymous
    March 25, 2010
    The comment has been removed

  • Anonymous
    July 05, 2010
    My program is ......... import java.sql.; import java.applet.; import java.awt.Graphics; /*<applet code=check1.class width=400 height=600> </applet> */ public class check1 extends Applet {    public void paint(Graphics g)    {         String s = connectsql();         g.drawString(s, 5, 15);    }    public String connectsql()    {         String sat_id= "sat_id";         String sat_name= "sat_name";         String ret = "";         try         {             //Driver d = (Driver)Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();             String url = "jdbc:sqlserver://localhost:1433;databaseName=master;selectMethod=cursor;";             java.sql.Connection con = null;             try             {                 con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433");                 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");                 con = java.sql.DriverManager.getConnection(url, sat_id, sat_name);                 if (con != null)                 {                     ret = "connected";                     con.close();                     con = null;                 }                 else                 {                     ret = "failed to connect";                 }              }             catch(ClassNotFoundException cnfe)             {                     ret = cnfe.toString();             }         }        catch (Exception e)         {             ret = "caught new driver exception: " + e.toString();         }        return ret;     } Each time I Run it with Appletviewer It shows Following Exception:::: 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 and how can I check my jdbc sql server 2005 ....and its path...

  • Anonymous
    July 05, 2010
    My program is ......... import java.sql.; import java.applet.; import java.awt.Graphics; /*<applet code=check1.class width=400 height=600> </applet> */ public class check1 extends Applet {    public void paint(Graphics g)    {         String s = connectsql();         g.drawString(s, 5, 15);    }    public String connectsql()    {         String sat_id= "sat_id";         String sat_name= "sat_name";         String ret = "";         try         {             //Driver d = (Driver)Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();             String url = "jdbc:sqlserver://localhost:1433;databaseName=master;selectMethod=cursor;";             java.sql.Connection con = null;             try             {                 con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433");                 Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");                 con = java.sql.DriverManager.getConnection(url, sat_id, sat_name);                 if (con != null)                 {                     ret = "connected";                     con.close();                     con = null;                 }                 else                 {                     ret = "failed to connect";                 }              }             catch(ClassNotFoundException cnfe)             {                     ret = cnfe.toString();             }         }        catch (Exception e)         {             ret = "caught new driver exception: " + e.toString();         }        return ret;     } Each time I Run it with Appletviewer It shows Following Exception:::: 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 and how can I check my jdbc sql server 2005 ....and its path...

  • Anonymous
    July 21, 2010
    The comment has been removed

  • Anonymous
    July 25, 2010
    place the sqljdbc4.jar file into u r web-inf -->lib;

  • Anonymous
    October 16, 2010
    If you are using an IDE like jDeveloper or eclipse, make sure you add the classpaths to the project properties/preferences options.

  • Anonymous
    October 19, 2010
    It would appear, that although Microsoft claims that both the 2.0 and 3.0 drivers work with JRE 1.5.  If I do I get a ClassNotFoundException or java.lang.UnsupportedClassVersionError: Bad version number in .class file Running under JRE 1.6 solves this problem.   Would Microsoft consider rebuilding de drivers with 1.5 compiler?  Clearly this was the intention.

  • Anonymous
    November 02, 2010
    santhosh  is right place the sqljdbc.jar or sqljdbc4.jar file into your web-inf -->lib; it worked for me

  • Anonymous
    November 02, 2010
    santhosh  is right place the sqljdbc.jar or sqljdbc4.jar file into your web-inf -->lib; it worked for me

  • Anonymous
    November 15, 2010
    The comment has been removed

  • Anonymous
    December 16, 2010
    Please let us know if someone has got this worked. I'm on the same boat as of PhilipG. curious to know, what did I miss. Please help.

  • Anonymous
    June 08, 2011
    Eclipse Package Explorer -> right click over project folder -> Properties -> Java Build Path -> Libraries -> Add External JARs... works for me

  • Anonymous
    October 26, 2011
    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.

  • Anonymous
    March 27, 2014
    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

  • Anonymous
    July 20, 2014
    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 Serversqljdbc_4.0enusqljdbc4.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!