Nonstop Database, HiRDB Version 9 UAP Development Guide

[Contents][Index][Back][Next]

18.6.2 ConnectionPoolDataSource interface

For details and usage information about the methods provided by the ConnectionPoolDataSource interface, see the JDBC documentation. This section shows the ConnectionPoolDataSource interface methods that are supported by the JDBC driver.

Organization of this subsection
(1) Methods
(2) Package and class names

(1) Methods

The following table lists the methods of the ConnectionPoolDataSource interface.

Table 18-59 ConnectionPoolDataSource interface methods

Subsection Method Function
(a) getLoginTimeout() Returns the value specified by the setLoginTimeout method.
(b) getLogWriter() Acquires the ConnectionPoolDataSource object's log writer.
(c) getPooledConnection() Acquires a PooledConnection object that can be used as a pooled connection, based on connection information set in the data source.
(d) getPooledConnection(String user, String password) Acquires a PooledConnection object that can be used as a pooled connection, based on connection information set in the data source.
(e) setLoginTimeout(int seconds) Specifies the maximum amount of time (in seconds) to wait for the connection to the database to be completed.
(f) setLogWriter(PrintWriter out) Sets a log writer for the ConnectionPoolDataSource object.
(a) getLoginTimeout()

Function
Returns the value specified by the setLoginTimeout method.

Format
 
public synchronized int getLoginTimeout() throws SQLException
 

Arguments
None.

Return value
int type:
Value specified by the setLoginTimeout method. If the setLoginTimeout method has not been specified, this method returns 0.

Exceptions
None.
(b) getLogWriter()

Function
Acquires the ConnectionPoolDataSource object's log writer.

Format
 
public synchronized PrintWriter getLogWriter() throws SQLException
 

Arguments
None.

Return value
This method returns the log writer for the PrdbConnectionPoolDataSource object. If no log writer has been set, the method returns the NULL value.

Exceptions
None.
(c) getPooledConnection()

Function
Acquires a PooledConnection object that can be used as a pooled connection, based on connection information set in the data source.

Format
 
public synchronized PooledConnection getPooledConnection() throws SQLException
 

Arguments
None.

Return value
PooledConnection object

Functional detail
This method returns a PooledConnection object that can be used as pooled connection, based on connection information that has been set in a DataSource object. For details about the specification method priorities for the user name and password, see 18.11 Connection information priorities.

Exceptions
JDBC driver throws an SQLException if a database access error has occurred.
(d) getPooledConnection(String user, String password)

Function
Acquires a PooledConnection object that can be used as a pooled connection, based on connection information set in the data source.

Format
 
public synchronized PooledConnection getPooledConnection(String user, String password) throws SQLException
 

Arguments
String user: User name used to establish connection
String password: Password used to establish connection

Return value
PooledConnection object

Functional detail
This method returns a PooledConnection object that can be used as a pooled connection, based on the information specified in the arguments and the connection information that has been set in a DataSource object.
When the null value is set in the user or password argument it means that the argument with the null value is not being used to set the user name or password. When the password argument contains a character string with a length of 0, it means that no password has been specified. When a user ID is specified in both the user argument and ConnectionProperty, the user argument takes precedence. Similarly, the password argument takes precedence for a password specification. For details about the specification priorities when the user and password arguments are not specified, see 18.11 Connection information priorities.

Exceptions
The JDBC driver throws an SQLException in the following cases:
  • A database access error occurred.
  • The user name specified in the argument is a character string with a length of 0.
(e) setLoginTimeout(int seconds)

Function
Specifies the maximum amount of time (in seconds) to wait for the connection to the database to be completed.

Format
 
public synchronized void setLoginTimeout(int seconds) throws SQLException
 

Arguments
int seconds: Maximum connection wait time (seconds)

Return value
None.

Functional detail
This method is used when physical connection is established with the HiRDB server in order for the getConnection method to acquire a Connection object. If 0 is specified or setLoginTimeout is not executed, the value specified in PDCONNECTWAITTIME is assumed as the maximum amount of time to wait for the HiRDB server to be physically connected.

Exceptions
If the seconds argument value is less than 0 or is greater than 300, the method throws an SQLException.
(f) setLogWriter(PrintWriter out)

Function
Sets a log writer for the ConnectionPoolDataSource object.

Format
 
public synchronized void setLogWriter(PrintWriter out)
 

Arguments
PrintWriter out: Log writer

Return value
None.

Exceptions
None.

(2) Package and class names

The names of the package and class for using this interface directly are as follows:

Package name: JP.co.Hitachi.soft.HiRDB.JDBC

Class name: PrdbConnectionPoolDataSource