Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Error occurs when using SQL in Query runner.

SA-52545

Summary



Error occurs when using SQL in Query runner.


Error Messages



There was a problem performing a database query: Database-General Problem encountered when getting connection for database pegadata 0 08003 This connection has been closed.
DatabaseException caused by prior exception: org.postgresql.util.PSQLException: This connection has been closed.
| SQL Code: 0 | SQL State: 08003



Steps to Reproduce



Run a query in Query Runner.


Root Cause



A defect or configuration issue in the operating environment.

Connections are not verified by the Application server before they are provided to Pega application for use. Consequently, they are stale and closed.


Resolution



Make the following change to the operating environment:

Add the below attributes to the Resource element for the jdbc/PegaRULES connection,


    testOnBorrow="true"
    testOnConnect="true"
    testOnReturn="true"
    testWhileIdle="true"
    validationQuery="select 1"


This causes the validation query to be executed at specific points in time, as follows:

testOnBorrow - If true, connections are validated before they are returned from the pool. If the validation fails, the connection is destroyed and a new connection is retrieved from the pool (and validated).

testOnConnect - The indication of whether objects will be validated when a connection is created. If an object fails to validate, SQLException occurs. 

testOnReturn -  If true, connections are validated before they are returned to the pool. If the validation fails, the connection is destroyed instead of being returned to the pool.

testWhileIdle - If true, connections will be validated by the idle connection evictor (if any). If the validation fails, the connection is destroyed  and removed from the pool.

The validation query above is valid for Postgres.

For long running queries that are disconnected, change the following:

   
removeAbandoned="true"
    removeAbandonedTimeout="some large number greater than the longest expected query"

 
Additionally, set  the following,
    
    
removeAbandoned="false"

The below setting logs abandoned connections,
   

    logAbandoned="true"

Refer to: https://community.pega.com/support/support-articles/connection-has-been-closed

Published November 29, 2018 - Updated October 8, 2020

Was this useful?

100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us