0

Now I am working with Microsoft SQLserver jdbc connectivity when I try to define class.forname

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

error occurs, everything else is fine, but I dint have any idea about this error.

pom.xml:

<dependency>
  <groupId>com.microsoft.sqlserver</groupId>
  <artifactId>sqljdbc4</artifactId>
  <version>4-2.0</version>
  <scope>system</scope>
  <systemPath>D:\my current work(please backup this folder)\backup\12-15-2016\milma_jishnu/src/main/lib/sqljdbc4-2.0.jar</systemPath>
</dependency>
2
  • did you check inside the .m2 folder if the jar is present or not? Commented Dec 31, 2016 at 6:18
  • yes it exist there Commented Dec 31, 2016 at 6:20

1 Answer 1

1

Quoting Maven documentation:

System Dependencies

Important note: This is marked deprecated.

Dependencies with the scope system are always available and are not looked up in repository. They are usually used to tell Maven about dependencies which are provided by the JDK or the VM. Thus, system dependencies are especially useful for resolving dependencies on artifacts which are now provided by the JDK, but where available as separate downloads earlier. Typical example are the JDBC standard extensions or the Java Authentication and Authorization Service (JAAS).

So, <scope>system</scope> tells Maven: This is already present, you don't need to do anything.

Ergo, it is not added to the classpath, and you wonder why it's not there?

Seems you misunderstood the purpose of <scope>system</scope>. Don't use it, because the MS SQL JDBC driver is not part of the JDK.

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

1 Comment

Use the compile or runtime scopes.

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.