1

I'm trying to connect to a SQLServer DB using JDBC. I'm using jre 1.6 and I've added the 'sqljdbc/jar' to my class path on my OS. I've also added that jar far to my build path. When my code hits this line Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); it explodes. I can navigate to the class in the package explorer, I can also type out the namespace and eclipse intellisense picks it up as well, yet when it loads I get java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver. I'm using Eclipse Indigo Release 2 w/ Spring STS plugin, can any one tell me whats going on? btw: I can connect to my db using the DB using DB Explorer in Eclipse.

3 Answers 3

1

Thank you eveyrone for your suggestions, here is how I solved it:

  1. I added the jar in question to my .m2 repository folder

  2. Opened Pom.xml => clicked Dependencies Tab => clicked Add

  3. Modeled a folder structure to match that of that of the attributes that I entered. For example jdbc\sqljdbc4\4\sqljdbc4-0.jar (I added -0 as it needs to have a version #)*

  4. Rebuild, Deploy and BAM!

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

Comments

0

Try to see if you have another jar file sqljdbc2.jar in the same location. Use that one. Also you may want to try jTDS driver for SQL server.

Comments

0

It could be that you have more than one library referencing com.microsoft.sqlserver.jdbc.SQLServerDriver, Check your driver or alternatively, try downloading a different version.

Sometimes doing a clean and build helps ( Project->Clean) , then build again might help.

Good luck

PB

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.