Configure the maximum number of seconds a connection can persist when connecting to Cloud SQL for PostgreSQL by using the HikariCP JDBC connection. pool library.
Documentation pages that include this code sample
To view the code sample used in context, see the following documentation:
// maxLifetime is the maximum possible lifetime of a connection in the pool. Connections that // live longer than this many milliseconds will be closed and reestablished between uses. This // value should be several minutes shorter than the database's timeout value to avoid unexpected // terminations. config.setMaxLifetime(1800000); // 30 minutes
To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.