0

I am trying to build a springboot application, with microsoft sql server connection. I build connection to mysql and it worked fine, but now i cannot connect to my mssql database, because springboot gradle script doesn't load the 'com.microsoft.sqlserver:sqljdbc4' jar. I tried to load the jar via gradle script in a non-springboot project and it worked fine. Is springboot doing something i don't know? Or is there another problem?

My gradle-script:

buildscript {
    ext {
        springBootVersion = '1.4.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'

jar {
    baseName = 'BEAT-Surflet'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('com.microsoft.sqlserver:sqljdbc4')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework:spring-jms')
    compile('org.apache.activemq:activemq-broker')  
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

Maybe the problem is, that springboot tries to load the version by himself or conflicting because of it. I tried to exlicit give him the version too ('com.microsoft.sqlserver:sqljdbc4:4.0'), but it didn't work either. So why my gradle-script or my springboot project doesn't load the mssql jar?

Issam El-atif
  • 2,366
  • 2
  • 17
  • 22
Anton Styopin
  • 753
  • 4
  • 17
  • 35
  • Possible duplicate of [Missing artifact com.microsoft.sqlserver:sqljdbc4:jar:4.0](http://stackoverflow.com/questions/19537396/missing-artifact-com-microsoft-sqlserversqljdbc4jar4-0) – Issam El-atif Oct 24 '16 at 09:34

2 Answers2

0

I had simmilar issues. I Solved this by using net.sourceforge.jtds 1.3.1. driver. I suggest using this driver for MSSQL databases. Microsoft driver is really bugged and it do not support of some widely used data types.

TomOw
  • 1,311
  • 1
  • 11
  • 18
  • JTDS does not support some SQL Server types, like UniqueIdentifier, and IIRC it also does not support JDBC4? Either way, JTDS does not work for my project, I have to use the MS driver – Developer Dude Oct 23 '17 at 23:16
0

I'm guessing you really want Spring Boot, not Gradle, to be able to use MS SQL Server -- Gradle just puts the dependency on the classpath.

You may need to specify spring.datasource.driver-class-name in you application properties/yml file. See the Working with SQL Databases section of the documentation.

Good luck.

Jamie Bisotti
  • 2,605
  • 19
  • 23