1

I am new to maven and my main, recuring, issue is having dependencies to be resolved.

In my pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>groupId</groupId>
    <artifactId>Toto</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <!-- NOT FOUND -->
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>8.1.1.jre8-preview</version>
            <scope>test</scope>
        </dependency>

        <!-- FOUND -->
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>8.1.1.jre13</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>

The first one cannot be resolved, while the second can. They both come from the same place.

https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc/8.1.1.jre13 https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc/8.1.1.jre8

Obviously, I need the first one. What is the issue ? IDE is IntelliJ

Milan
  • 1,547
  • 1
  • 24
  • 47
  • 1
    I'm having the same issue, if I use `7.4.1.jre8` then it works. I also found that having `test` doesn't load the JDBC driver at runtime so I also removed that. I have maven 3.6.3 – Archmede Jan 20 '20 at 04:45
  • I have tried with both the Bundled maven in IntelliJ and I've also tried changing IntelliJ to use my `maven home` which is version `3.6.3` – Archmede Jan 20 '20 at 04:55
  • Thank you, yes it is working with this version. I assume the issue is maven sided then. I now have another problem when trying to connect to the DB, which is: "Exception in thread "main" java.sql.SQLException: No suitable driver found for url" I do load the driver with Class.forname(...) and the db can be manually connected. But it's another subject. – Milan Jan 20 '20 at 14:16
  • The reason it's not working is because the JAR doens't exists. If you go to https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc/8.1.1.jre8 and then click the view all link then you'll get a 404. Someone must've made a mistake trying to upload the JAR. – Archmede Jan 20 '20 at 17:13
  • As for your other issue ` Class.forname(...) ` shouldn't be needed anymore. Also, remove `test` from you POM because it won't load the driver at runtime which might be causing your `java.sql.SQLException`. Step through your code and when the connection is being created make sure the driver exists because if it doesn't then it can throw that exception. As I said before try removing the `` tag. Otherwise make sure your connection URL is in the proper format. You may also need to configure your server to accept TCP/IP connections. – Archmede Jan 20 '20 at 17:15

0 Answers0