Top
Symfoware Server V12.1.0 Application Development Guide
FUJITSU Software

2.3.2 Using the PGConnectionPoolDataSource Class

To connect to databases using data sources, specify the connection information in the properties of the data source.

Method description

Argument

Description

setServerName

Specify the host name for the connection destination.

setPortNumber

Specify the port number for the database server.

The default is "26500".

setDatabaseName

Specify the database name.

setUser

Specify the username of the database.

By default, the name used will be that of the user on the operating system that is executing the application.

setPassword

Specify a password for server authentication.

setLoginTimeout

Specify the timeout for connections (in units of seconds).

Specify a value between 0 and 9223372036854775. There is no limit set if you set 0 or an invalid value.

An error occurs when a connection cannot be established within the specified time.

setSocketTimeout

Specify the timeout for communication with the server (in units of seconds).

Specify a value between 0 and 2147483647. There is no limit set if you set 0 or an invalid value.

An error occurs when data is not received from the server within the specified time.

setMaxStatements

Specify the number of statements to be cached.

Specify an integer value between 0 and 2147483647. The default is 0.

The statement caching feature will be disabled if 0 is specified. An error will not occur if an invalid value is specified, however, the behavior will be as if 0 has been specified.

Refer to "2.4.2 Statement Caching Feature" for information on this feature.

Example

Code examples for applications

import java.sql.*;
import org.postgresql.ds.PGConnectionPoolDataSource;
...
PGConnectionPoolDataSource source = new PGConnectionPoolDataSource();
source.setServerName("sv1");
source.setPortNumber(26500);
source.setDatabaseName("mydb");
source.setUser("myuser");
source.setPassword("myuser01");
source.setLoginTimeout(20);
source.setSocketTimeout(20);
source.setMaxStatements(20);
...
Connection con = source.getConnection();