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/03/08 22:25:39 UTC

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

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
    Priority: Minor
     Fix For: 10.2.0.0


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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Derby Info: [Patch Available]

> 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


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

Posted by "David Van Couvering (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12371312 ] 

David Van Couvering commented on DERBY-1090:
--------------------------------------------

Hi, Olav.  It's not clear to me what a committer needs to do with this patch.  You have checked the box saying you intend it for inclusion to the project, but you also say other, alternate patches are on  the way.  Do you want a committer to commit this, or is it just for review?

> 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: 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Other Info:   (was: [Patch available])

> 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: 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


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

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12371245 ] 

Daniel John Debrunner commented on DERBY-1090:
----------------------------------------------


The query case actually seems somewhat harder to me, and one needs to understand the code far more, than the isClosed approach.
Maybe this knowledge needs to exist for the client implementation anyway. I think one has to see how many ways the query can fail and
then see how many map to the connection being not valid. I don't believe the query failing, always means the connection is not valid.
If the query failed due to out of memory error, then the connection is still valid.

There's no requirement for the embedded and client dirver to have identical implementations, the embedded gains performance
by having direct access to the engine, something that is clearly not possible with the client. This naturally leads to different implementations
for various methods.

> 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

>
> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]
     
Olav Sandstaa closed DERBY-1090:
--------------------------------


> 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: brokeredlogical1090.diff, 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Attachment: embedded1090-query.diff

The patch contains one alternative implementation of  Connection.isValid() for the embedded driver by verifying that the connection
is open (by calling isClosed()) and by running a simple query ("VALUES (1)") against the database. If the connection is closed or if the query returns any SQL exception, isValid returns false. To support the timeout defined as a parameter to isValid, setQueryTimeout is used.

Testing:

The patch extends the TestConnectionMethods.java test with test for isValid in the following cases:

  -wrong parameter values (negative timeout)
  -isValid with no timeout
  -isValid with a specified timeout
  -isValid on a connection that is closed
  -isValid on a "open connection" to a database that is shutdown

I plan to submit an alternative patch that is checking only for isClosed as well as a more complete patch containing an implementation of isValid for the Derby client driver.

svn status reports:

M      java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnection.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java

I have run the JDBC4 tests using Java 1.6 and derbyall using 1.5 under Solaris 10 x86. Only errors seen in the regression test was reported.

The patch is complete for the embedded driver and could be reviewed and committed, but I expect that we should wait until we have decided if using only isClosed is a better and sufficient solution.



> 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: 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ 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


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

Posted by Daniel John Debrunner <dj...@apache.org>.
Oystein Grovlen - Sun Norway wrote:

> Olav Sandstaa (JIRA) wrote:
> 
>> Dan has suggested that checking for isClosed could be sufficient in
>> the embedded version. It would be good to hear if other have opinions
>> about this. If I do not get other suggestions I will probably propose
>> that the next patch (checking only for isClosed) being reviewed and
>> commited.
> 
> 
> Since the API spec, explicitly mentions running a query to validate the
> connection, I think it would be best to do that. 

No, the API javadoc says:

"The driver shall submit a query on the connection or use some other
mechanism that positively verifies the connection is still valid"

Note the "or use some other mechanism".

> Also, it does not seem
>  very meaningful to add a new method that does exactly the same as an
> existing method.

The definition of Connection.isClosed() is different to isValid(),
that's why isValid was added in JDBC 4.0. For a client side JDBC driver
the implementation will typically be different for isClosed() and
isValid(), only in the embedded driver can they be implemented the same way.

Dan.




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

Posted by Oystein Grovlen - Sun Norway <Oy...@Sun.COM>.
Olav Sandstaa (JIRA) wrote:

> Dan has suggested that checking for isClosed could be sufficient in the embedded version. It would be good to hear if other have opinions about this. If I do not get other suggestions I will probably propose that the next patch (checking only for isClosed) being reviewed and commited.

Since the API spec, explicitly mentions running a query to validate the 
connection, I think it would be best to do that.  Also, it does not seem 
  very meaningful to add a new method that does exactly the same as an 
existing method.

-- 
Øystein

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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12371422 ] 

Olav Sandstaa commented on DERBY-1090:
--------------------------------------

Hi, David. The main purpose of sending in the patch was to get opinions from more people on what would be the best alternative solution to check if a connection is valid in the embedded driver. The current alternatives are:

  a) check if connection is not closed followed by a simple query against the database (this is implemented by the patch I submitted yesterday)
  b) just check that the connection is not closed (I plan to submit an alternative patch for this soon)

Dan has suggested that checking for isClosed could be sufficient in the embedded version. It would be good to hear if other have opinions about this. If I do not get other suggestions I will probably propose that the next patch (checking only for isClosed) being reviewed and commited.

> 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: 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


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

Posted by "Daniel John Debrunner (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12371161 ] 

Daniel John Debrunner commented on DERBY-1090:
----------------------------------------------

In embedded would it  be sufficient just to call the isClosed() method?


> 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

>
> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]
     
Olav Sandstaa resolved DERBY-1090:
----------------------------------

    Resolution: Fixed

> 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: brokeredlogical1090.diff, 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Attachment: embedded1090-isclosed.diff

This patch (embedded1090-isclosed.diff)  implementations Connection.isValid() for the embedded driver by verifying that the connection 
is not closed (by calling isClosed()). If the connection is closed, isValid returns false, otherwise it returns true. The timeout defined as a parameter to isValid is not used.

Compared to the previous patch I sent a few days ago (embedded1090-query.diff), this patch does not run any query against Derby to validate the
connection. My proposal (also based on suggestions from Dan) is that we only check for isClosed() in the embedded driver. I have not experienced any situation where isClosed returned false and the query failed. If we later discover situations where the connection is not "valid" even if isValid returns true, we can add a query as done in my first patch to isValid.

Testing: 

The patch extends the TestConnectionMethods.java test with test for isValid in the following cases: 

  -wrong parameter values (negative timeout) 
  -isValid with no timeout 
  -isValid with a specified timeout 
  -isValid on a connection that is closed 
  -isValid on a "open connection" to a database that is shutdown 

svn status reports: 

M      java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestConnectionMethods.java

I have run the JDBC4 tests using Java 1.6 and derbyall using Java 1.5 under Solaris 10 x86. Only errors seen in the regression test was reported (runtimeinfo failed in derbynetmats).

The patch is complete for the embedded driver and 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: 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

Olav Sandstaa reassigned DERBY-1090:
------------------------------------

    Assign To: Olav Sandstaa

> 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

>
> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Attachment: brokeredlogical1090.diff

This patch (brokeredlogical1090.diff) implemets support for Connection.isValid for pooled and XA connections. 

Testing of isValid for pooled and XA connections is implemented in the jdbc4/ConnectionTest.junit. This test is currently not part of either the jdbc4 suite or derbyall. 

svn status reports:

M      java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
M      java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionTest.java
M      java/client/org/apache/derby/client/am/LogicalConnection40.java

I have run the jdbc4/ConnectionTest.junig, the JDBC4 test suite 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: brokeredlogical1090.diff, 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Derby Info: [Patch Available]

> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12371210 ] 

Olav Sandstaa commented on DERBY-1090:
--------------------------------------

Dan, thanks for the suggestion of only using isClosed in the embedded driver. I have also wondered if calling isClosed would be sufficient, and actually I have not been able to create a scenario where isClosed returns false followed by simple query that fails.

The main reasons for including execution of a simple query also in the embedded driver are:

 * I do not know the code well enough to be sure that there will not be situations where isClosed returns false and a query returns e.g., a timeout or exception due to some resource constraints, deadlock or other error situations.

 * It will make the behavior and implementation more similar between what is done in the embedded and in the client driver.

I will probably submit a patch for how isValid can be implemented for the Embedded server containing both a check for isClosed and a query. If you or other on the list still thinks it is unnecessary to include execution of a query I will remove it.


> 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

>
> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Other Info: [Patch available]

> 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: 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


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

Posted by "Rick Hillegas (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12376938 ] 

Rick Hillegas commented on DERBY-1090:
--------------------------------------

Looks solid. JDBC4 tests run cleanly. So does derbyall modulo the wisconsin noise. Committed at subversion revision 397899.

> 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


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

Posted by "Rick Hillegas (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12375649 ] 

Rick Hillegas commented on DERBY-1090:
--------------------------------------

I concur, looks good. JDBC4 tests run cleanly. Derbyall runs cleanly modulo wisconsin noise. Committed at subversion revision 396028.

> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12376267 ] 

Olav Sandstaa commented on DERBY-1090:
--------------------------------------

The first implementation of Connection.isValid() for the client driver handles most failuire situations. One situation that is not handled is if the server "hangs" and the client does not receive a reply. The application will be hanging "forever" in the isValid() call due to the blocking read on the socket even if a timeout value has been specified. I plan to submit a fix to this problem by setting a timeout on the socket before the read is called on the socket (using java.net.socket.setSoTimeout). One potential problem with using socket.setSoTimeout is that its implementation is platform dependent. Some operating systems might not support the timeout value and block forever on socket operations even if a timeout is set.

I would appreciate to hear if anybody has better or alternative solutions on how to handle the problem with blocking socket read and hanging server. 



> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12371306 ] 

Olav Sandstaa commented on DERBY-1090:
--------------------------------------

Thanks for commenting on this, Dan. I agree that using a query is more complicated than just checking for isClosed. So if checking for isClosed is sufficient to verify that the connection is "valid" we should go for that approach in the embedded driver as it is less complex and has better performance. 

Still, I think the purpose of adding the isValid method to the JDBC standard is to positively determine that it is possible to run queries on it. I am not convinced that your example of a simple query on the connection failing due to out of memory should still return that the connection is "valid"? I expect this is a method that will be used together with a connection pool implementation where either the pool or the user will use this for "ensuring" the connection is "valid" before it is used for something. And having a connection that returns out of memory errors on every query is not something that an application would think is a "useful" connection to have around (on the other side, creating a new connection does probably not make the situation any better in this case). The JavaDoc for isValid (see the test in the Jira issue) strongly indicates that we actually should take the cost of running a query against the database.

Anyway, I have no strong opinions on whether to just check isClosed or issue a query against the database. But since I now happen to have a patch that solves this using a query I will upload this patch tonight. Tomorrow moring I will upload a new patch that is only checking for isClosed. I do not expect anyone to do a review or commit any of these, but it might trigger some more comments and opinions from other on the list. 

> 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

>
> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Derby Info:   (was: [Patch Available])

Dyre and Rick, thanks for reviewing and committing the patch.

> 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1090?page=all ]

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

    Derby Info:   (was: [Patch Available])

> 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: brokeredlogical1090.diff, 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


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

Posted by "Rick Hillegas (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12371853 ] 

Rick Hillegas commented on DERBY-1090:
--------------------------------------

Looks good to me. The jdbc4 tests run cleanly. Derbyall only has errors which I see in a clean client: wisconsin, sysinfo, sysinfo_withproperties, xaSimplePositive, and a new failure in SURTest caused by:

> java.lang.NoSuchMethodError: main
> Exception in thread "main"
Test Failed.

I have committed embedded1090_isClosed.diff at subversion revision 388771.

> 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: 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


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

Posted by "Olav Sandstaa (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12371144 ] 

Olav Sandstaa commented on DERBY-1090:
--------------------------------------

In case someone else have suggestions or ideas on how to best implement this functionality, here are some high-level initial thoughts on how to implement it:

  -to check the validity of the connection, issue a simple query like
   e.g., "VALUES (1)"

  -to implement the timeout, use the setQueryTimeout() method. 

This will hopefully be sufficient in the embedded version as I expect that for all error situations where the connection no longer is valid, an exception will be thrown when issuing the query.

For the Derby client we probably need some timeout mechanism in the client code (in addition to setting the query timeout) in order to detect that the server has not responded within before the specified timeout has elapsed. I have not studied the network code in details yet to find out if it already has code or hooks for specifying a timeout on the DRDA request to the server. Any suggestions on how to best implement this are welcome.


> 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

>
> 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


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

Posted by "Dyre Tjeldvoll (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12375577 ] 

Dyre Tjeldvoll commented on DERBY-1090:
---------------------------------------

I have looked at the patch, and I think it looks good, and can be 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


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

Posted by "Rick Hillegas (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1090?page=comments#action_12383384 ] 

Rick Hillegas commented on DERBY-1090:
--------------------------------------

The brokeredlogical1090.diff patch looks solid. JDBC4 tests pass. Derbyall passes modulo expected diffs in wisconsin and SuicideOfStreaming. Committed at subversion revision 406101.

> 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: brokeredlogical1090.diff, 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