You can connect to a database via an application using the DriverManager, PGConnectionPoolDataSource, and PGXADataSource JDBC driver classes.
The following is an example of using the PGConnectionPoolDataSource class to connect to a database:
import java.sql. *; import org.postgresql.ds.PGConnectionPoolDataSource; ... PGConnectionPoolDataSource source = new PGConnectionPoolDataSource (); source.setServerName ("sv1"); source.setPortNumber (27500); source.setDatabaseName ("mydb"); source.setUser ("myuser"); source.setPassword ("myuser01"); source.setLoginTimeout (20); source.setSocketTimeout (20); ... Connection con = source.getConnection ();
For details, refer to Fujitsu Enterprise Postgres Application Development Guide > Chapter 2 - JDBC driver > 2.3 - Connecting to the database.
Product: Fujitsu Enterprise Postgres SE, Fujitsu Enterprise Postgres AE, PostgreSQL
Versions: from 9.5
Architecture: X86, S390x
Operating System: Windows, Linux
The query can be cancelled by using the pg_cancel_backend function, and connections can be forcibly broken using either the pg_terminate_backend function or pgAdmin.
In the pg_cancel_backend and pg_terminate_backend functions, the process ID specifies the query to cancel or connection to break. The process ID can be found in the pg_stat_activity view or with the OS ps command.
Product: Fujitsu Enterprise Postgres SE, Fujitsu Enterprise Postgres AE, PostgreSQL
Versions: from 9.5
Architecture: X86, S390x
Operating System: Windows, Linux
This may have happened because the application was trying to work on a Connection object that had already been closed.
Review your application's handling of Connection objects as follows:
Product: Fujitsu Enterprise Postgres SE, Fujitsu Enterprise Postgres AE, PostgreSQL
Versions: from 9.5
Architecture: X86, S390x
Operating System: Windows, Linux
Possible causes include the following:
Resolution
Consider making the following changes:
Product: Fujitsu Enterprise Postgres SE, Fujitsu Enterprise Postgres AE, PostgreSQL
Versions: from 9.5
Architecture: X86, S390x
Operating System: Windows, Linux
It is possible that the application is not disconnecting from the database, leaving unnecessary connections and exceeding the maximum number of connection pools.
If a connection is requested beyond the maximum number of connection pools, it will wait until an available connection is found. If no available connection is found and the connection timeout period is exceeded, the connection request will timeout.
Resolution
Check the connection that has been waiting for a long time, and close any unnecessary connection.
Also, ensure that the application is disconnecting from the database. If it already is, please review the maximum number of connection pools specified in the connection string - this is specified by the Maximum Pool Size keyword, and the default is 100.
Product: Fujitsu Enterprise Postgres SE, Fujitsu Enterprise Postgres AE, PostgreSQL
Versions: from 9.5
Architecture: X86, S390x
Operating System: Windows, Linux
This happened because PREPARE TRANSACTION was performed with the max_prepared_transactions parameter set to 0 in postgresql.conf.
Resolution
Set max_prepared_transactions to at least 1 in postgresql.conf.
Product: Fujitsu Enterprise Postgres SE, Fujitsu Enterprise Postgres AE, PostgreSQL
Versions: from 9.5
Architecture: X86, S390x
Operating System: Windows, Linux
ODBC drivers cannot be installed separately - they are installed with the Fujitsu Enterprise Postgres client.
Product: Fujitsu Enterprise Postgres SE, Fujitsu Enterprise Postgres AE, Fujitsu Enterprise Postgres for Kubernetes, PostgreSQL
Versions: from 9.5
Architecture: X86, S390x
Operating System: Windows, Linux
Read our most recent articles regarding all aspects of PostgreSQL and FUJITSU Enterprise Postgres.