0

I am trying to develop my first Java web application with a Postgres database. I am receiving the error Method

org.postgresql.jdbc4.Jdbc4Connection.isValid(int) is not yet implemented

while launching the application.java.

I tried the solutions here, here and here without success.

Below the details of the classes.

Application properties:

spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
spring.datasource.url=jdbc:postgresql://localhost:5432/db_notespesa
spring.datasource.username=postgres
spring.datasource.password=password

Application.java

package notaSpese;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}

POM file

<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>notaSpeseNew</groupId>
  <artifactId>notaSpeseNew</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>notaSpeseNew</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
  </parent>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
      <!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
    <dependency>
      <groupId>postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>9.1-901-1.jdbc4</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate.javax.persistence</groupId>
      <artifactId>hibernate-jpa-2.1-api</artifactId>
      <version>1.0.0.Final</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>5.2.1.Final</version>
    </dependency>
  </dependencies>

  <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
  </build>

</project>
  • 1
    Have you tried a higher version of the JDBC driver e.g. something like 9.4.x? https://mvnrepository.com/artifact/org.postgresql/postgresql/9.4.1212 – Sami Altundag Dec 15 '18 at 15:20
  • If I replace the line version of the POM in the dependency of postgresql with 9.4.1212 (taken from here: https://mvnrepository.com/artifact/org.postgresql/postgresql/9.4.1212) I have an error: Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource: Property: driverclassname Value: org.postgresql.Driver Origin: "driverClassName" from property source "source" Reason: Failed to load driver class org.postgresql.Driver in either of HikariConfig class loader or Thread context classloader – Marco Giuseppe de Pinto Dec 15 '18 at 15:25
  • 1
    The driver is in the jar file. Are you sure you have the jar in the project libraries? If you use Eclipse, you can run mvn eclipse:eclipse and then refresh the project to make sure the project reads the new dependency. – Sami Altundag Dec 15 '18 at 15:34
  • Running the command the build has been completed with a warning: [WARNING] Missing POM for postgresql:postgresql:jar:9.4.1212 [WARNING] An error occurred during dependency resolution. Failed to retrieve postgresql:postgresql-9.4.1212 Caused by: Failure to find postgresql:postgresql:jar:9.4.1212 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced – Marco Giuseppe de Pinto Dec 15 '18 at 15:42
  • If I put 9.1-901-1.jdbc4 I have no errors. – Marco Giuseppe de Pinto Dec 15 '18 at 15:43
  • Solved, there was a typo in the groupId org.postgresql postgresql 9.4.1212 – Marco Giuseppe de Pinto Dec 15 '18 at 15:46
  • java version "11.0.1" 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode) – Marco Giuseppe de Pinto Dec 15 '18 at 15:53

1 Answers1

0

Solved, there was a typo in the groupId of the POM.

<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>9.4.1212</version>
</dependency>