You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Olav Sandstaa (JIRA)" <de...@db.apache.org> on 2006/04/21 15:38:20 UTC

[jira] Updated: (DERBY-1090) Implement Connection.isValid as defined by JDBC4

     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

Olav Sandstaa updated DERBY-1090:
---------------------------------

    Attachment: client1090_patch1.diff

This patch (client1090_patch1.diff) implements the Connection.isValid for the network client. The connection is valid if (a) it is not closed (checked isClosed()) and (b) a simple query ("VALUES (1)") is executed successfully. Any exception thrown by the query execution is treated as if the connection is not valid.

If a timeout is specified this is handled by setting a query timeout for executing the query (queryTimeout() is used). 

The implementation handles most failure situations, with the exception of a hanging server that is not returning any reply to the client. I plan to submit a fix for this in a separte patch. 

The isValid() call is tested for the following scenarios:

  -illegal parameter values (negative timeout)
  -no timeout value
  -with a timeout specified
  -on a connection to a database that has been shutdown
  -on a connection to a network server that has been stopped

svn status reports:

M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java
M      java/client/org/apache/derby/client/net/NetConnection40.java

I have run the JDBC4 tests and derbyall with the patch. Only failure was in tools/derbyrunjartest.java.

The patch can be reviewed and committed.

> Implement Connection.isValid as defined by JDBC4
> ------------------------------------------------
>
>          Key: DERBY-1090
>          URL: http://issues.apache.org/jira/browse/DERBY-1090
>      Project: Derby
>         Type: Sub-task

>   Components: JDBC
>     Reporter: Olav Sandstaa
>     Assignee: Olav Sandstaa
>     Priority: Minor
>      Fix For: 10.2.0.0
>  Attachments: client1090_patch1.diff, embedded1090-isclosed.diff, embedded1090-query.diff
>
> The Javadoc for JDBC4 says this about Connection.isValid:
> boolean isValid(int timeout) throws SQLException
> Returns true if the connection has not been closed and is still valid. The driver shall submit a query on the connection or use some other mechanism that positively verifies the connection is still valid when this method is called. 
> The query submitted by the driver to validate the connection shall be executed in the context of the current transaction. 
> Parameters: timeout - - The time in seconds to wait for the database operation used to validate the connection to complete. If the timeout period expires before the operation completes, this method returns false. A value of 0 indicates a timeout is not applied to the database operation. 
> Returns: true if the connection is valid, false otherwise 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira