SQL workbench This connection has been closed in few minutes - postgresql

I use SQL workbench to connect postgresql. But I frequently get following error
This connection has been closed.
when ever I kept the window idle for 2-3 minutes.
I am not sure where to the change the settings. Please help me .
Version : Build 118.7

If the server is configured to disconnect idle connections, you can configure a statement that is sent to the database server in regular intervals.
This is done in the connection profile. Click on the "Connect scripts" button:
Connection dialog
Then enter a statement for "Statement to keep connection alive".
Connect scripts
In the "Idle time" you can configure how often the statement should be executed. "1m" means that it's run every minute unless you run statements manually (or do something in the DbExplorer)
This should prevent the server to disconnect your session.

Related

intermittent "connection reset by peer" sql postgres

After a period of inactivity, my go web service is getting a net.OpError with message read tcp x.x.x.x:52086->x.x.x.x:24414: read: connection reset by peer when executing the first postgres sql query. After the error, the subsequent requests will work fine.
The postgres database is hosted with compose.com which has haproxy in front of the postgres db. My go web app is using standard sql and sqlx.
I've tried running a ticker invoking db.Ping() every 15 minutes, but this hasn't fixed the issue.
Why is the go standard sql lib not handling these connection drops?
Since no one wrote that explicity. The solution to this problem is setting db.SetConnMaxLifetime(time.Minute). I tried it and it works. Connection reset occurs often on AWS where there is inactivity limit set to 350 seconds, after that TCP RST is returned.

How to change PostgreSQL Studio's inactivity timeout?

I want to increase PostgreSQL's Studio login/session time out time. When I leave PostgreSQL Studio to idle just for some time, I get the following message:
You have been logged out due to inactivity. Please relogin or exit.
I am using PostgreSQL from BigSQL 5.0.3 package bundle. Actually, I am researching about compability of MS SQL Server and PostgreSQL queries.
As I am using Postgres now for learning purpose rather than security, I feel it annoying to login frequently.
How can I increase the login/session timeout inside PostgreSQL Studio?
Postgres itself doesn't have an idle connection timeout. This is coming from something else.
Unfortunately, the timeout value is hard-coded to 30 minutes in PostgreSQL Studio. You should only see that if you are not using Studio at all for 30 minutes. Its a pretty simple matter to move that property to the config file so it can be changed. We just need to write a patch.
The timeout is to prevent Studio from holding open idle connections to PostgreSQL. PostgreSQL Studio uses connection pooling to manage connections back to the database so if the browser connection goes away without logging out, we need a way to remove those connections.

How to set connection timeout value for pgAdmin?

I am using pgAdmin to connect remotely to my database as phpPgAdmin is a bit limited in its features. Only problem is if I leave the SQL window open without running a query for a few minutes, then it says I need to reconnect.
Is this a setting I need to change in my database to keep remote connections alive for longer or is it a pgAdmin setting?
It is client setting.
You need specify connect_timeout in your config file.
29.1. Database Connection Control Functions
29.14. The Connection Service File

Does database connection stay opened except for errors and explicit closure?

Assuming that no statements to close the connection are made before my script ends and no exception is encountered before closing the connection, does the database's connection stay open?
I'm connecting to the database programmatically via Python Psycopg2 and via Java JDBC4 driver.
Not entirely sure what you want exactly, but let's try:
You can see the connections that exist at any time with PGAdmin or this SQL command
SELECT * FROM pg_stat_activity;
It should be fairly simple to spot when - for your specific use case - the connection closes.
If an SQL query is running at the time you close a connection, I think it will run to completion, ie the backend serving it will remain alive, even if the connection is closed from the client side.

How can UNCLOSED connection be found in OC4J/Oracle?

I fixed and use Connection Pool to get the DB Connection from JSP to Oracle Database now.
But then I found out from the OC4J console at once that there are many UNCLOSED/NOT-CLOSED connection.
I am using OC4J 9.0.4.1 and Oracle 10g. Is there any effective way to find out the location or area that the connection is not closed.
In addition, I would like to know the followings:
1) The UNCLOSED connection means the Connection or ResultSet or Statment ?
2) IF Connection for the ResultSet and Statement is closed, the corresponding ResultSet and Statement are closed automatically too ?
I'd expect that this is easiest to detect on the server side - one assumes (!) that there is a 'show me all the open connections' report or command on the server that should show up a list of those connections together with the last executed SQL on that connection (am coming from the MSSQL side of things here - this doesn't sound like too much of a stretch, tho').
Unclosed means that the connection has not been closed.