0

I am trying to use the Microsoft SQL Server 2008 Type 4 JDBC Driver in a java desktop application.

However when I run the program I get the following error--

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

How do I overcome this error? The code looks to be OK as it is...Its a single sql statement to be executed into local sql server 2008 database.

1 Answer 1

2

Make sure that the .jar containing this driver is in your CLASSPATH. Here's an article explaining how to setup this.

Sign up to request clarification or add additional context in comments.

4 Comments

There are 2 Jar files in the driver for SQL Server 2008, I added both of those jars to the classpath variable, however I am still getting the same error?? (Note that the article you have helpfully linked to refers to jars for SQL Server 2000 so file names given there are different from those that I have with me for SQL Server 2008)...
@user893664, yes indeed the article I have linked to is for SQL Server 2000, but the same principles apply. The .jat files must in the CLASSPATH. It's simple. If you get this error it means that your are not.
ok i checked, what you are saying is correct... Couple of things that I want to add- Sometimes in Windows if the jar is in a folder whose name>8 chars, then it may not work, in such case put the jar in C:\jdbc\ (or something else with folder name's length<=8 chars) and then add this to class path.... Also the JAR also has to be registered in the IDE (in addition to specifying class path in system settings). Thanks a ton for your help Darin...
@user893664, those are very good points that you brought. Indeed they are all important and must be taken care of. I am glad that you managed to get this working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.