12

The connection to SQL Workbench/J gets disconnected very frequently. Where can I change the settings so that it does not lose the connections for atleast an hour.

Thanks

Amy123
  • 902
  • 9
  • 15

2 Answers2

13

This works for me with using PostgreSQL...

  1. Go to Connection Window
  2. Select the connection you want to keep alive
  3. Click the "Connect scripts" button
  4. Write "Select 1" in the third box titled "Statement to keep connection alive"
  5. Write "1m" in fourth box titled "Idle time"

SQL Workbench/J (screenshot)

amz
  • 131
  • 1
  • 3
  • Just in case anyone sees this, for the iSeries DB2, use "VALUES 1" instead of "SELECT 1". – Kelly Beard Dec 04 '17 at 15:45
  • @amz a quick question. what do "select 1" and "1m" stand for in this case? – Anita Jan 27 '19 at 04:04
  • On windows, the 'Connect scripts button' was hidden inside the connection window, after seeing your screenshot, I had resize the connection window, I was able to find the 'connect scripts' button. I had frequent problems with sqlworkbenchj UX (I cant find editor window sometimes) and google search always shows results for the other sqlworkbench. – mosh Aug 09 '20 at 06:49
1

What OS are you using and what type of database are you connecting to?

I had the same issue using Windows connecting to a Redshift database. I followed the instructions on Amazon doing the following:

  • Edit (or otherwise create if not already existing in my case) the values for the following registry settings under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters:

    • KeepAliveTime: 30000
    • KeepAliveInterval: 1000
    • TcpMaxDataRetransmissions: 10

Reference here: http://docs.aws.amazon.com/redshift/latest/mgmt/connecting-firewall-guidance.html

crazy8
  • 308
  • 3
  • 16