Question

I am using a software that requires jbdc driver (for sql server 2005), my java version is 1.5.0_16.

When I want to start the application, it throws me this exception :

java.sql.SQLException: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
Was it helpful?

Solution

The CLASSPATH variable is the search string that Java Virtual Machine (JVM) uses to locate the JDBC drivers on your computer. If the drivers are not listed in your CLASSPATH variable, you receive the following error message when you try to load the driver:

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

The JDBC driver is not part of the Java SDK. If you want to use it, you must set the classpath to include the sqljdbc.jar file or the sqljdbc4.jar file. If the classpath is missing an entry for sqljdbc.jar or sqljdbc4.jar, your application will throw the common "Class not found" exception.

The sqljdbc.jar file and sqljdbc4.jar file are installed in the following location:

<installation directory>\sqljdbc_<version>\<language>\sqljdbc.jar
<installation directory>\sqljdbc_<version>\<language>\sqljdbc4.jar

The following is an example of the CLASSPATH statement that is used for a Windows application:

CLASSPATH =.;C:\Program Files\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\sqljdbc.jar 

The following is an example of the CLASSPATH statement that is used for a Unix/Linux application:

CLASSPATH =.:/home/usr1/mssqlserverjdbc/Driver/sqljdbc_4.0/enu/sqljdbc.jar 

You must make sure that the CLASSPATH statement contains only one Microsoft JDBC Driver for SQL Server, such as either sqljdbc.jar or sqljdbc4.jar.

For more information, please see:

support ms

msdn ms

OTHER TIPS

Is the driver class name correct?

Shouldn't it be

"com.microsoft.sqlserver.jdbc.SQLServerDriver"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top