Top
Symfoware Server V12.1.0 Application Development Guide
FUJITSU Software

11.2.6 Using Embedded SQL

It is recommended that you use a connection service file. Refer to "11.2.4 Using a Connection Service File" for details.

Point

If using a connection service file, either of the following methods is available:

  • Set the service name as a string literal or host variable, as follows:

    tcp:postgresql://?service=my_service

  • Set the service name in the environment variable PGSERVICE, and use CONNECT TO DEFAULT

If a connection service file will not be used, use a literal or variable to specify the connection destination server information for target in the SQL statement below:

EXEC SQL CONNECT TO target [AS connection-name] [USER user-name];

Method used
dbname@host1,host2[:[port1][,port2]]
tcp:postgresql://host1,host2[:[port1][,port2]] [/dbname] [?target_server={primary | prefer_standby}][&sslmode=verify-full&sslservercertcn=targetServerCertificateCN]
  • The above format cannot be specified directly without using a literal or variable.


Table 11.6 Information to be set

Argument

Explanation

host1
host2

Specify the IP address or host name. IPv6 format addresses cannot be specified.

port1
port2

Specify the connection destination port numbers, using a comma as the delimiter.
The port number can be omitted. If omitted, the default is 26500.

dbname

Specify the database name.

target_server

Specify the selection sequence of the servers to which the application will connect.
Refer to "Target server" for details.

sslmode

Specify this to encrypt communications. By default, this is disabled. The setting values for sslmode are as follows:

disable: Connect without SSL

allow: Connect without SSL, and if it fails, connect with SSL

prefer: Connect with SSL, and if it fails, connect without SSL

require: Connect always with SSL

verify-ca: Connect with SSL, using a certificate issued by a trusted CA (*1)

verify-full: Connect with SSL, using a certificate issued by a trusted CA to verify if the server host name matches the certificate (*1)

sslservercertcn

This parameter is enabled only to perform SSL authentication (sslmode=verify-full).

Specify the server certificate CN. If this is omitted, the value will be null, and the server certificate CN will be authenticated using the host name specified in host.

*1: If specifying either "verify-ca" or "verify-full", use the system environment variable PGSSLROOTCERT (connection parameter sslrootcert) of your operating system to specify the CA certificate file as shown below.

Example)
Variable name: PGSSLROOTCERT
Variable value: cACertificateFile


Point

Environment variables can also be used. Refer to "11.2.5 Using the C Library (libpq)" for information on environment variables.


Note

If using the connection parameter connect_timeout, this value is applied for connections to each of the specified hosts. If both multiplexed database servers have failed, the connection will time out when a time equal to double the connect_timeout value elapses.