ClassNotFoundException: com.microsoft.sqlserver.jd

2020-02-15 06:59发布

问题:

When I ran my web application under Eclipse IDE everything worked fine. But when I exported my project into war-file and deployed in tomcat I've got following message:

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

I've tried putting sqljdbc4.jar everywhere:

  • catalina-home\lib dir
  • WEB-INF\lib dir
  • both of them

What I'am missing? Environment: tomcat 6.0.20, sql server 2005

回答1:

Your driver class name is wrong. The exception text points to a package, not an actual driver class. And don't forget to restart Tomcat after changing the contents of various lib directories.

Edit: Your IDE might use different configuration than your deployed war. Or fail with the same exception silently but the driver itself was already loaded by other means - then the actual connection just works.



回答2:

The driver class is "com.microsoft.sqlserver.jdbc.SQLServerDriver". You've just missed the class name off the end.



回答3:

blah... After reinstalling tomcat it worked just fine. As kd304 said - maybe it was configuration issue Thanks for your help



标签: java jdbc