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

半腔热情 提交于 2019-11-28 09:38:37

That method is implemented in the current driver version. You must be using an old PgJDBC. Upgrade. It's fully backward compatible. (You should've specified your PgJDBC version in the question).

Separately, though, relying on connection "validation" is usually a bad idea. It's just a way of trying to imperfectly hide a race condition. Simply grab the connection and use it. If there's a problem with it, your application should trap the resulting exception, check the SQLSTATE to see if it's a connection related error, and retry with a new connection.

Replace your postgresql with below entry in pom.xml. My Postgress version was postgresql-9.3.10-3.

<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>9.3-1100-jdbc41</version>
</dependency>

Craig has right. The root cause is postgresql group id changed to org.postgresql and the old group doesn't get the updates. You should refresh your dependency node i.e.:

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

according to the current latest version https://mvnrepository.com/artifact/org.postgresql/postgresql/

Solution: Set a validation query for parameter "validationQuery".

E.g for bean: property name="validationQuery" value="SELECT 1"

This validation query is run against the connection before returning it. So have a valid query, above is a dummy one.

https://commons.apache.org/proper/commons-dbcp/configuration.html

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.3-1100-jdbc41</version>
    </dependency>

changed the driver, it works!

This ticket helped me to solve the issue: Caused by: java.lang.NoSuchMethodError: org.postgresql.core.BaseConnection.getEncoding()Lorg/postgresql/core/Encoding;

Basically, you need to exclude PostGIS stubs:

 <dependency>
   <groupId>org.postgis</groupId>
   <artifactId>postgis-jdbc</artifactId>
   <version>1.3.3</version>
   <scope>compile</scope>
   <exclusions>
      <exclusion>
         <groupId>org.postgis</groupId>
         <artifactId>postgis-stubs</artifactId>
      </exclusion>
   </exclusions>
</dependency>

Maven Central has an old version of the driver under postgresql. Check for org.postgresql.

intelliJ safe definition (which resolves to 9.4.1208-jdbc42-atlassian-hosted)

<dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>RELEASE</version>
</dependency>

OR:

<dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.5.jre7</version>
        </dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!