Classpath set, but: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

无人久伴 提交于 2019-11-28 12:20:40

If you pass -jar to java.exe then the classpath is taken from the specified Jar file's manifest; all external classpath settings (e.g. %CLASSPATH%) are ignored.

Do one of:

  1. Use java -cp ...\myapp.jar MainClassName

  2. Put sqljdbc.jar into the Class-Path field in myapp.jar's manifest.

  3. Discover and load sqljdbc.jar programmatically.

copy sqljdbc4.jar under WebContent-->WEB_INF -->lib folder. This resolved my problem.

MIkka Marmik

set the class path for sqljdbc4.jar

CLASSPATH= D:\sqljdbc_4.0.2206.100_enu\sqljdbc_4.0\enu\sqljdbc4.jar;

if you are eclipse user remove unnecessary .jar file sqljdbc

Rolmo2

If you programme application ZK, then put sqljdbc4.jar in the folder WebContent -> WEB_INF -> lib .

Reference: Anand's comment.

Open a new command prompt, and try with steps as below, its not good to work inside C:\WINDOWS\system32

The issue says the sqljdbc4.jar is not properly set in the classpath.

        C:\Test
        set classpath=%classpath%;.;c:\temp\sqljdbc4.jar
        java -jar "C:\Users\MYUSER\Documents\NetBeansProjects\myappSource\dist\myappSource.jar" -u MYUSER -p MYPASS -j "jdbc:sqlserver://127.0.0.1\\msqlserver:1433;database=MYDB"

I got this error after updating my Eclipse STS, it turned out my server forgot all of its configuration info during the update. I had to set up the server's classpath and environment variables all over again and that fixed the issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!