This version of the JDBC driver is only compatible with Elasticsearch version vUnknown [Unknown],

hello everyone,jdbc driver get version error

use jdbc 6.7.1

org.elasticsearch.plugin x-pack-sql-jdbc 6.7.1

mvn clean package

Maven runs after packaging

java.sql.SQLException: This version of the JDBC driver is only compatible with Elasticsearch version vUnknown [Unknown], attempting to connect to a server version 6.7.1
at org.elasticsearch.xpack.sql.jdbc.JdbcHttpClient.checkServerVersion(JdbcHttpClient.java:94)
at org.elasticsearch.xpack.sql.jdbc.JdbcHttpClient.(JdbcHttpClient.java:43)
at org.elasticsearch.xpack.sql.jdbc.JdbcConnection.(JdbcConnection.java:49)
at org.elasticsearch.xpack.sql.jdbc.EsDriver.connect(EsDriver.java:76)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.example.demo.TestController.getConnection(TestController.java:36)
at com.example.demo.TestController.selectCount(TestController.java:48)
at com.example.demo.TestController.test(TestController.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at

@zhu1289303556 I've tested this version of the driver in a simple java application and I'm not seeing this behavior. Can you post the Maven pom file you are using in this test?

<?xml version="1.0" encoding="UTF-8"?>


4.0.0

org.springframework.boot
spring-boot-starter-parent
2.2.2.RELEASE


com.example
demo
0.0.1-SNAPSHOT
demo
Demo project for Spring Boot

<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <mybatis.plus.version>3.1.1</mybatis.plus.version>
    <aliyun-sdk-oss.version>2.8.2</aliyun-sdk-oss.version>
    <swagger.ui>2.9.2</swagger.ui>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.freemarker</groupId>
        <artifactId>freemarker</artifactId>
        <version>2.3.28</version>
    </dependency>

    <!-- lombok -->
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>

    <!--elasticsearch-->
    <dependency>
        <groupId>org.elasticsearch.plugin</groupId>
        <artifactId>x-pack-sql-jdbc</artifactId>
        <version>6.7.1</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.2.2.RELEASE</version>
    </dependency>

</dependencies>

<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>


<repositories>
    <repository>
        <id>elastic.co</id>
        <url>https://artifacts.elastic.co/maven</url>
    </repository>
</repositories>

<profiles>
    <profile>
        <id>dev</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <profileActive>dev</profileActive>
        </properties>
    </profile>
    <profile>
        <id>test</id>
        <properties>
            <profileActive>test</profileActive>
        </properties>
    </profile>
    <profile>
        <id>prod</id>
        <properties>
            <profileActive>prod</profileActive>
        </properties>
    </profile>
</profiles>

@Andrei_Stefan

I am not familiar with Spring Boot applications... what cluster does it attempt to access?

  • what version of Elasticsearch (server side)?
  • is the cluster embedded in this Spring Boot application somehow?
  • can you test the JDBC driver outside this Spring Boot application?

When using springboot with
elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your pom.xml:

<properties>
  <elasticsearch.version>7.3.0<elasticsearch.version>
</properties>

See documentation here: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions

May be not your problem here but I prefer sharing.

@dadoonet @Andrei_Stefan
put x-pack-sql-jdbc-6.7.1.jar into "jre/ lib/ext /" and it can execute normally. I think it's the classloader of springboot that loads the x-pack-sql-jdbc quoted by Maven and can't read the version. Check org.elasticsearch.xpack.sql.client.Version URL url = Version.class.getProtectionDomain().getCodeSource().getLocation(); no information can be obtained.

Elasticsearch is 6.7.1

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.