1

I created a new Play 2.5.3 project and I'm getting this error.

I read in another answer the driver was out of date, so I added what I believe to be the latest driver like this:

I added the postgress driver dependency like this:

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs,
  "postgresql" % "postgresql" % "9.1-901-1.jdbc4"
)

But still getting the error. Any idea how to fix this?

1
  • 1
    The most recent version is "org.postgresql" % "postgresql" % "9.4.1208". Commented Jun 1, 2016 at 4:07

1 Answer 1

2

It seems that this function is really not implemented in version 9.1-901 of the driver
see a source code: http://grepcode.com/file/repo1.maven.org/maven2/postgresql/postgresql/9.1-901.jdbc4/org/postgresql/jdbc4/AbstractJdbc4Connection.java#AbstractJdbc4Connection.isValid%28int%29

117    public boolean isValid(int timeout) throws SQLException
118    {
119        checkClosed();
120        throw org.postgresql.Driver.notImplemented(this.getClass(), "isValid(int)");
121    }

You can use a newer version of the driver, currently the newest driver is: Version 9.4-1208, see this link: https://jdbc.postgresql.org/


Or you can implement this funcion on your own - you can copy their implementation from here:
http://grepcode.com/file/repo1.maven.org/maven2/org.postgresql/postgresql/9.4-1201-jdbc41/org/postgresql/jdbc4/AbstractJdbc4Connection.java#AbstractJdbc4Connection.isValid%28int%29

127    public boolean isValid(int timeout) throws SQLException
128    {
129        if (isClosed()) {
130            return false;
131        }
132     if (timeout < 0) {
133            throw new PSQLException(GT.tr("Invalid timeout ({0}<0).", timeout), PSQLState.INVALID_PARAMETER_VALUE);
134        }
135     boolean valid = false;
136        Statement stmt = null;
137     try {
138         if (!isClosed()) {
139             stmt = createStatement();
140             stmt.setQueryTimeout( timeout );
141             stmt.executeUpdate( "" );
142             valid = true;
143         }
144     }
145     catch ( SQLException e) {
146         getLogger().log(GT.tr("Validating connection."),e);
147     }
148     finally
149     {
150         if(stmt!=null) try {stmt.close();}catch(Exception ex){}
151     }
152        return valid;    
153}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.