Help Center> Data Warehouse Service (DWS)> Troubleshooting> Database Use> JDBC Error Occurs Due to session_timeout Settings
Updated on 2022-12-26 GMT+08:00

JDBC Error Occurs Due to session_timeout Settings

Symptom

The following error message is displayed when using JDBC to connect to the cluster and run COPY to import data:
org.postgresql.util.PSQLException: Database connection failed when starting copy at org.postgresql.core.v3.QueryExecutorImpl.startCopy(QueryExecutorImpl.java:804) at org.postgresql.copy.CopyManager.copyIn(CopyManager.java:52) at org.postgresql.copy.CopyManager.copyIn(CopyManager.java:161) at org.postgresql.copy.CopyManager.copyIn(CopyManager.java:146) at copy.main(copy.java:95) Caused by: java.io.EOFExceptionat org.postgresql.core.PGStream.ReceiveChar(PGStream.java:284) at org.postgresql.core.v3.QueryExecutorImpl.processCopyResults(QueryExecutorImpl.java:1008) at org.postgresql.core.v3.QueryExecutorImpl.startCopy(QueryExecutorImpl.java:802) ... 4 more

Possible Causes

session_timeout is set to 10min by default. That is, a database is automatically disconnected if the connection is idle for more than 10 minutes.

Handling Procedure

Log in to the GaussDB(DWS) management console and set session_timeout to 0 or a long duration to ensure the session can stay connected for a long time.

  1. Log in to the GaussDB(DWS) management console. In the cluster list, find the target cluster and click the cluster name. The Cluster Information page is displayed.
  2. Click the Parameter Modifications tab and modify the value of parameter session_timeout. Click Save.

After the COPY import is complete, you are advised to set session_timeout to 10 minutes. A client connected to the database creates a thread. If the client does not perform any operation on the database for a long time, the thread is idle. If there are a large number of such clients, the connection resources will be wasted.