classNotFoundException in Loading JDBC Driver

前端 未结 3 1769
花落未央
花落未央 2020-12-18 17:41

I am a newbie in java and I\'m developing a Java EE application on the Netbeans 6.9.1 IDE. I have to connect my java application with SQL Server 2005.

For that I ha

相关标签:
3条回答
  • 2020-12-18 17:47

    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
    
    0 讨论(0)
  • 2020-12-18 17:52

    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> 
    
    0 讨论(0)
  • 2020-12-18 18:00

    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.

    0 讨论(0)
提交回复
热议问题