db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olav Sandstaa (JIRA)" <derby-...@db.apache.org>
Subject [jira] Updated: (DERBY-1090) Implement Connection.isValid as defined by JDBC4
Date Thu, 27 Apr 2006 20:15:39 GMT
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Attachment: client1090_patch2.diff

This patch (client1090_patch2.diff) addresses the problem of Connection.isValid() hanging
infinite if the server is either "hanging" or not sending a reply. 

The reason for the client to hang in these situations is that blocking read (and write) is
used for receiving replies from the Derby network server. To avoid the client hanging infinite
in the blocking read when the caller has specified a timeout to isValid() we set a maximum
timeout value on the socket (by using java.net.socket.setSoTimeout()) before the query is
sent to the server. Thus, if the server does not respond within the specified timeout period
the blocking read will return with an exception.
If this exception is thrown, isValid will return false for this connection. The timeout on
the socket is reset to whatever value it had before the call to isValid. Thus, this socket
timeout should only influence on the query issued by the isValid code.

The implementation has been tested by setting a very low timeout value and introducing a delay
in the network server.

svn status reports:

M      java/client/org/apache/derby/client/net/NetAgent.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, client1090_patch2.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


Mime
View raw message