Add option File->Options->General->Query Windows->[Auto-reconnect connection on execution if it is closed]. Default value is false.
Use this API to determine if connection is closed : http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#isValid%28int%29
See AFScriptContext.executeScriptStatements() line 2035. Before this, we can check to see if the option above is enabled. If it is, then we check to see if the connection isValid( 15 seconds ). If it is not, then we try to establish a new connection. We need to add a status text in the status bar indicating that we are reconnecting, because the .connect() method could hang based on network conditions. If it hangs, we need to make sure there is an indicator to the user that it is trying to connect. Clicking the cancel button while it is hanging may not stop the reconnect, so we need to consider this also.
If there is a reconnect, we need to make sure we propagate the new connection back the the Query Window and update the SPID. Also, if Connection Pooling is enabled, we will ignore the auto-reconnect option.
If the auto-reconnect option is disabled and the user executes a statement on a disconnected connection, we want the error message to the user to include a message telling the user that he can enable auto-reconnect in the File->Options ... see AFScriptContext line 2037.
Only these databases use the isValid method - Oracle, Sybase Any, IQ, ASE, MySQL, Derby, Hive Cloudera(Simba Drivers), Informix, Vertica.
The rest of the databases use isClosed as isValid is not available. Apache drivers for Hive do not support isValid but Simba drivers does support this method. I have not tested the Amazon drivers. I suspect they implemented isValid.
I verified in AWS SQL Server and MySQL and it is working fine. I will complete the rest of the RDBMS with the help of QA Team and update the status.
I verified in AWS SQL Server and MySQL and it is working fine. I will complete the rest of the RDBMS with the help of QA Team and update the status.
Change the message from:
You can enable auto-reconnect in the "File->Options->General->Query Windows" window.
to
You can enable auto-reconnect in "File->Options->General->Query Windows->Auto-reconnect on execution if connection is closed"
Change the message from:
You can enable auto-reconnect in the "File->Options->General->Query Windows" window.
to
You can enable auto-reconnect in "File->Options->General->Query Windows->Auto-reconnect on execution if connection is closed"
For databases that do not use the isValid method and use the isClosed method to test the connection, we could have a scenario where an execute of a query on a terminated session will give an execute error instead of doing a reconnect. You will have to re-execute the query a second time to do the reconnect. The reason is that the method isClosed doesn't know that the session with the server was terminated. isClosed will return a false and so no reconnect will take place just the execute. This is normal behavior until all databases implement the isValid method. Tariq mentioned this in his test note.
For databases that do not use the isValid method and use the isClosed method to test the connection, we could have a scenario where an execute of a query on a terminated session will give an execute error instead of doing a reconnect. You will have to re-execute the query a second time to do the reconnect. The reason is that the method isClosed doesn't know that the session with the server was terminated. isClosed will return a false and so no reconnect will take place just the execute. This is normal behavior until all databases implement the isValid method. Tariq mentioned this in his test note.
Only these databases use the isValid method - Oracle, Sybase Any, IQ, ASE, MySQL, Derby, Hive Cloudera(Simba Drivers), Informix, Vertica, DB2 LUW and DB2 z/OS.
Only these databases use the isValid method - Oracle, Sybase Any, IQ, ASE, MySQL, Derby, Hive Cloudera(Simba Drivers), Informix, Vertica, DB2 LUW and DB2 z/OS.
Only these databases use the isValid method - Oracle, Sybase Any, IQ, ASE, MySQL, Derby, Hive Cloudera(Simba Drivers), Hive(Amazon Simba Drivers) Informix, Vertica, DB2 LUW and DB2 z/OS.
Only these databases use the isValid method - Oracle, Sybase Any, IQ, ASE, MySQL, Derby, Hive Cloudera(Simba Drivers), Hive(Amazon Simba Drivers) Informix, Vertica, DB2 LUW and DB2 z/OS.
Made a fix in ADS v16.0.5-11 specifically for Sybase Anywhere, ASE and IQ which was not working previously. Also retested the connection pooled enabled scenario. See attached.
Made a fix in ADS v16.0.5-11 specifically for Sybase Anywhere, ASE and IQ which was not working previously. Also retested the connection pooled enabled scenario. See attached.
Issue #13108 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build ADS 16.0.0-rc-14 |
No time estimate |
Only these databases use the isValid method - Oracle, Sybase Any, IQ, ASE, MySQL, Derby, Hive Cloudera(Simba Drivers), Informix, Vertica.
The rest of the databases use isClosed as isValid is not available. Apache drivers for Hive do not support isValid but Simba drivers does support this method. I have not tested the Amazon drivers. I suspect they implemented isValid.