classNotFoundException in Loading JDBC Driver

北城以北 提交于 2019-11-29 09:01:05

You need to check the JDBC driver documentation which came along with your SQL server version. In the old SQL Server 2000, the JDBC driver class name is like as you have:

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

However, since SQL Server 2005, Microsoft changed the JDBC driver class name:

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

Fix it accordingly.

Please note that the CLASSPATH environment variable is ignored by Netbeans and all other decent Java programs. Forget about it and don't even try to set it until you understand why it exists and what it is to be used for.

Can you try:

set classpath=.;"C:\Program Files (x86)\Microsoft SQL Server\JDBC Drver\lib\sqljdbc.jar"

If this does not, try replacing folders with spaces in their names with short name. To get short names, try

dir /-n

If you use Maven, you can try adding following to pom.xml:

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