4

I'm trying to connect to a MSSQL using the MS JDBC Driver (Microsoft SQL Server JDBC Driver 3.0: http://www.microsoft.com/download/en/details.aspx?id=21599) but what every i do i get java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver when i run the project in Netbeans.

I am running Netbeans 7.1 on Windows 7 Enterprise 64-bit. I have gone through quite a few guides on the web on how to setup the MSSQL JDBC driver but I know I'm missing something. Does anyone have a fool/idiot proof guide to setting this up, I don't care how basic it is. I'm sure its something in my enviroment that isn't correct and I'm only just starting out with Java and Netbeans so I suspect I've overlooked something.

1
  • Check whether the Driver Jar file lies in your classpath. Commented Feb 23, 2012 at 6:05

3 Answers 3

6

You might have the package for the SQLServerDriver class incorrect. Try "com.microsoft.sqlserver.jdbc.SQLServerDriver" instead of "com.microsoft.jdbc.sqlserver.SQLServerDriver".

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

3 Comments

Also as Shashank pointed out, ensure the sqljdbc4.jar or sqljdbc.jar are in your classpath.
Thanks a lot for that, it's got me over that hurdle, i knew it was going to be something simple.
No problem! Another note... jar files are really just zip files. So if you change the extension to .zip, you can look inside and see the organization of the class structure. That's what I did in this case and I've never used this particular driver ;)
3

I your project tree listing pane, under libraries see if the JDBC package is listed if not right click on the library node -> Add JAR/Folder. Then browse the right package from your computer and import it. I think this should solve the problem.

And as you asked this link might be helpful Creating a Simple Application Using MYSQL DB

Comments

0

In NETBEANS add path in the Project properties -> libraries -> compile tab screen image -> [https://i.sstatic.net/g6BH3.jpg]

Comments

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.