Skip to content Skip to sidebar Skip to footer

How To Connect Sql Server Through Java Code?

I am creating application where I need to connect my services to sql server. When I run the test code after adding dependency, it runs successfully. This is the test code which run

Solution 1:

Your dependency's scope is test, which means it will not be in the classpath when the application runs normally (not as a test). Change the scope to runtime, in which case classes inside the .jar will be available in run-time both if you run the application in the IDE or use a Maven plugin to package it.

Solution 2:

If you are still facing the issue with maven , you can download sqlserver jar file separately and add it in your project and try to run again.below is the path to download jar file.

http://java2s.com/Code/Jar/s/Downloadsqlserverjdbcjar.htm

Solution 3:

Unfortunately Microsoft doesn't make this artifact available via any maven repository . I would suggest you to use below dependency to resolve your issue

Microsoft has published some their drivers to maven central:

<dependency><groupId>com.microsoft.sqlserver</groupId><artifactId>mssql-jdbc</artifactId><version>6.1.0.jre8</version></dependency>

Post a Comment for "How To Connect Sql Server Through Java Code?"