Top
Symfoware Server V12.0.0 Application Development Guide
FUJITSU Software

2.3.4 Using the PGXADataSource 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 that will connect with the database.

If this is omitted, the name used will be that of the user on the operating system that is executing the application.

setPassword

Specify a password when authentication by a password is required.

setLoginTimeout

Specify the timeout for connections.

The units are 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.

The units are 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.

Example

Code examples for applications

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