com.intersystems.jdbc

## Class IRISConnectionPoolDataSource

- java.lang.Object
- - com.intersystems.jdbc.IRISWrapper
  - - com.intersystems.jdbc.ConnectionParameters
    - - com.intersystems.jdbc.IRISDataSource
      - - com.intersystems.jdbc.IRISConnectionPoolDataSource

All Implemented Interfaces:
  Cloneable, Wrapper, CommonDataSource, ConnectionPoolDataSource, DataSource

    public class IRISConnectionPoolDataSource
    extends IRISDataSource
    implements ConnectionPoolDataSource

`IRISConnectionPoolDataSource` object is an implementation of `ConnectionPoolDataSource` interface In addition to the apis defined by the interface, this class also includes a number of InterSystems IRIS specific apis. There are apis that can be used to limit (and view) the max connection pool size, view current pool size, and reset the current connection pool. Connections should always be obtained by calling getConnection apis, which are inherited from the `DataSource` class. getPooledConnection apis are meant for use within the driver only, and should not be used by the calling applications.

### Field Summary

Fields
`protected com.intersystems.jdbc.LogFileStream` `logFile`

### Fields inherited from class com.intersystems.jdbc.ConnectionParameters

`autobalance, isolationLevel, isPiped, keyRecoveryPassword, principalName, sqlDialect, sSLConfigName`

### Constructor Summary

Constructors
Constructor and Description
`IRISConnectionPoolDataSource()`

### Method Summary

All Methods Instance Methods Concrete Methods
`String` `getAccessToken()` Returns a `String` representing the current AccessToken.
`int` `getConnectionLifetime()` Returns the connectionLifetime for the DataSource
`int` `getConnectionSecurityLevel()` Returns an `int` representing current Connection Security Level setting.
`int` `getConnectionWaitTimeout()` Returns the current Connection Wait Timeout.
`String` `getDatabaseName()` Returns a `String` representing the current database (InterSystems IRIS Namespace) name.
`String` `getEventClass()` Returns a `String` representing the Event Class object.
`int` `getFeatureOption()` Returns an `int` representing the current Feature Option setting.
`com.intersystems.jdbc.LogFileStream` `getLogFile()` Returns a `LogFileStream` as the current log file instance.
`String` `getLogFileName()` Returns a `String` representing the current log file path.
`PrintWriter` `getLogWriter()` Returns a `PrintWriter` as the current log file instance.
`int` `getMaxPoolSize()` Returns the current Connection Pool max size
`int` `getMinPoolSize()` Returns the current Connection Pool minimum size
`boolean` `getNodelay()` Returns a `boolean` representing the current TCP_NODELAY flag setting.
`String` `getPassword()` Returns a `String` representing the current password.
`com.intersystems.jdbc.IRISPool` `getPool()` Returns the current Connection Pool for this DataSource
`int` `getPoolCount()` Returns the current Connection Pool size
`PooledConnection` `getPooledConnection()` IMPORTANT: this api SHOULD NOT be used to obtain a pooled connection.
`PooledConnection` `getPooledConnection(String usr, String pwd)` IMPORTANT: this api SHOULD NOT be used to obtain a pooled connection.
`int` `getPortNumber()` Returns an `int` representing the current port number.
`String` `getServerName()` Returns a `String` representing the current host.
`Boolean` `getSharedMemory()` Returns an `boolean` representing whether or not shared memory connections are enabled for this `DataSource` object.
`String` `getURL()` Returns a `String` representing a current URL for this `DataSource` object.
`String` `getUser()` Returns a `String` representing the current username.
`boolean` `getValidateOnConnect()` Returns the PingOnConnect setting for the DataSource
`void` `restartConnectionPool()` Restarts a Connection Pool.
`void` `setAccessToken(String token)` Sets the AccessToken for this `DataSource` object.
`void` `setConnectionLifetime(int conLifeTime)` Sets the current ConnectionLifetime
`void` `setConnectionWaitTimeout(int timeout)` Set the connection wait timeout.
`void` `setFeatureOption(int feature)` Sets the current Feature Option setting.
`void` `setFeatureOption(String sfeature)` Sets the current Feature Option setting.
`void` `setLogFile(com.intersystems.jdbc.LogFileStream lf)` Sets a `LogFileStream` as the current log file.
`void` `setLogFile(String fileName)` Sets an `String` representing the current log file path.
`protected void` `setLogFileNoThrow(String fileName)`
`void` `setLogWriter(PrintWriter pw)` Sets a `PrintWriter` as the current log file.
`void` `setMaxPoolSize(int max)` Sets a Connection Pool max size.
`void` `setMinPoolSize(int min)` Sets the current Connection Pool min size, This will be the initial number of pooled idle connections established
`void` `setURL(String u)` Sets the url for this `DataSource` object.
`void` `setValidateOnConnect(boolean p)` Sets the current PingOnConnect setting
`int` `validatePoolCount()` Returns the current Connection Pool size after pinging idle connections

### Methods inherited from class com.intersystems.jdbc.IRISDataSource

`getConnection, getConnection, getDataSourceName, getDefaultTransactionIsolation, getDescription, getKeyRecoveryPassword, getLoginTimeout, getParentLogger, getPreparseCacheSize, getServicePrincipalName, getSSLConfigurationName, getStreamPrefetchSize, setCommitTimeout, setConnectionSecurityLevel, setDatabaseName, setDataSourceName, setDefaultTransactionIsolation, setDescription, setEventClass, setKeyRecoveryPassword, setLoginTimeout, setNetworkTimeout, setNodelay, setPassword, setPortNumber, setPreparseCacheSize, setServerName, setServicePrincipalName, setSSLConfigurationName, setStreamPrefetchSize, setUser`

### Methods inherited from class com.intersystems.jdbc.ConnectionParameters

`addToPool, clone, copy, getHash, getSQLDialect, getTransactionIsolationLevel, isPooled, setSharedMemory, setSQLDialect, setTransactionIsolationLevel, updateConParams`

### Methods inherited from class com.intersystems.jdbc.IRISWrapper

`isWrapperFor, unwrap`

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface javax.sql.CommonDataSource

`getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriter`

### Methods inherited from interface java.sql.Wrapper

`isWrapperFor, unwrap`

### Field Detail

#### logFile

    protected com.intersystems.jdbc.LogFileStream logFile

### Constructor Detail

#### IRISConnectionPoolDataSource

    public IRISConnectionPoolDataSource()

### Method Detail

#### getPooledConnection

    public PooledConnection getPooledConnection()
                                         throws SQLException

IMPORTANT: this api SHOULD NOT be used to obtain a pooled connection. Use getConnection() instead.

Specified by:
  `getPooledConnection` in interface `ConnectionPoolDataSource`
Throws:
  `SQLException` - throws SQLException

#### getPooledConnection

    public PooledConnection getPooledConnection(String usr,
                                                String pwd)
                                         throws SQLException

IMPORTANT: this api SHOULD NOT be used to obtain a pooled connection. Use getConnection(String user, String pwd) instead.

Specified by:
  `getPooledConnection` in interface `ConnectionPoolDataSource`
Parameters:
  `usr` - username
  `pwd` - password
Throws:
  `SQLException` - throws SQLException

#### restartConnectionPool

    public void restartConnectionPool()
                               throws SQLException

Restarts a Connection Pool. Closes all physical connections, and empties the Connection Pool.

Throws:
  `SQLException` - throws SQLException

#### getPoolCount

    public int getPoolCount()

Returns the current Connection Pool size

Returns:
  pool size

#### validatePoolCount

    public int validatePoolCount()
                          throws SQLException

Returns the current Connection Pool size after pinging idle connections

Returns:
  pool size after validation
Throws:
  `SQLException` - - failed cleaning connections

#### getPool

    public com.intersystems.jdbc.IRISPool getPool()

Returns the current Connection Pool for this DataSource

Returns:
  pool

#### setAccessToken

    public void setAccessToken(String token)
                        throws SQLException

Sets the AccessToken for this `DataSource` object.

Overrides:
  `setAccessToken` in class `IRISDataSource`
Parameters:
  `token` - accesstoken
Throws:
  `SQLException`

#### setMaxPoolSize

    public void setMaxPoolSize(int max)

Sets a Connection Pool max size. If the max size is not set, it defaults to 40.

Parameters:
  `max` - max pool size

#### getMaxPoolSize

    public int getMaxPoolSize()

Returns the current Connection Pool max size

Returns:
  max pool size

#### setMinPoolSize

    public void setMinPoolSize(int min)

Sets the current Connection Pool min size, This will be the initial number of pooled idle connections established

Parameters:
  `min` - pool size

#### getMinPoolSize

    public int getMinPoolSize()

Returns the current Connection Pool minimum size

Returns:
  min pool size

#### setConnectionWaitTimeout

    public void setConnectionWaitTimeout(int timeout)

Set the connection wait timeout. See getConnectionWaitTimeout for more details on Connection Wait Timeout.

Parameters:
  `timeout` - the connectionWaitTimeout to set

#### getConnectionWaitTimeout

    public int getConnectionWaitTimeout()

Returns the current Connection Wait Timeout. This is the time, in seconds, that a Connection Pool Manager will wait for any connections to become available. If the pool is not full, and the connection is available, it will immediately be returned, regardless of whether the Connection Wait Timeout value has been set. Otherwise, the Connection Pool Manager will wait exactly timeout seconds before making another attempt to acquire a connection. Should there be no connections available after the timout period has expired, an exception will be thrown. Connection Wait Timeout defaults to zero, which means that the connection will either be immediately made available, or an exception will be thrown indicating that the pool is full.

Returns:
  the connectionWaitTimeout

#### setConnectionLifetime

    public void setConnectionLifetime(int conLifeTime)

Sets the current ConnectionLifetime

Parameters:
  `conLifeTime` - connection lifetime

#### getConnectionLifetime

    public int getConnectionLifetime()

Returns the connectionLifetime for the DataSource

Returns:
  connectionLifetime

#### setValidateOnConnect

    public void setValidateOnConnect(boolean p)

Sets the current PingOnConnect setting

Parameters:
  `p` - ping boolean value

#### getValidateOnConnect

    public boolean getValidateOnConnect()

Returns the PingOnConnect setting for the DataSource

Returns:
  ping boolean value

#### getURL

    public String getURL()

Returns a `String` representing a current URL for this `DataSource` object.

Returns:
  url

#### setURL

    public void setURL(String u)
                throws SQLException

Sets the url for this `DataSource` object.

Parameters:
  `u` - url
Throws:
  `SQLException` - throws SQLException

#### getUser

    public String getUser()

Returns a `String` representing the current username.

Returns:
  username to connect

#### getPassword

    public String getPassword()

Returns a `String` representing the current password.

Returns:
  password

#### getAccessToken

    public String getAccessToken()

Returns a `String` representing the current AccessToken.

Returns:
  accesstoken

#### getServerName

    public String getServerName()

Returns a `String` representing the current host.

Returns:
  current host name

#### getPortNumber

    public int getPortNumber()

Returns an `int` representing the current port number.

Returns:
  port number of host to connect with

#### getDatabaseName

    public String getDatabaseName()

Returns a `String` representing the current database (InterSystems IRIS Namespace) name.

Returns:
  namespace

#### getEventClass

    public String getEventClass()

Returns a `String` representing the Event Class object.

Returns:
  event Class

#### getNodelay

    public boolean getNodelay()

Returns a `boolean` representing the current TCP_NODELAY flag setting.

Returns:
  tcp nodelay value

#### getConnectionSecurityLevel

    public int getConnectionSecurityLevel()

Returns an `int` representing current Connection Security Level setting.

Returns:
  connection security level

#### getSharedMemory

    public Boolean getSharedMemory()

Returns an `boolean` representing whether or not shared memory connections are enabled for this `DataSource` object.

Returns:
  shared memory requested

#### getLogFile

    public com.intersystems.jdbc.LogFileStream getLogFile()

Returns a `LogFileStream` as the current log file instance.

Returns:
  instance of stream that writes a log

#### getFeatureOption

    public int getFeatureOption()

Returns an `int` representing the current Feature Option setting.

#### setFeatureOption

    public void setFeatureOption(int feature)
                          throws SQLException

Sets the current Feature Option setting.

The only permitted values are 0, 1, 2, 3... found in Feature.optionAllowedOptions.

Throws:
  `SQLException` - if `feature` is not in Feature.optionAllowedOptions.

#### setFeatureOption

    public void setFeatureOption(String sfeature)
                          throws SQLException

Sets the current Feature Option setting.

The only permitted values are 0, 1, 2, 3... found in Feature.optionAllowedOptions.

Throws:
  `SQLException` - if `feature` is not in Feature.optionAllowedOptions.

#### setLogFile

    public void setLogFile(String fileName)
                    throws SQLException

Sets an `String` representing the current log file path.

Parameters:
  `fileName` - path and filename of log file to use Use "" value to disable logging
Throws:
  `SQLException` - - Invalid log file name

#### setLogFileNoThrow

    protected void setLogFileNoThrow(String fileName)

#### setLogFile

    public void setLogFile(com.intersystems.jdbc.LogFileStream lf)

Sets a `LogFileStream` as the current log file.

Parameters:
  `lf` - instance of a logfileStream to use

#### getLogWriter

    public PrintWriter getLogWriter()

Returns a `PrintWriter` as the current log file instance.

Returns:
  printWriter for logging instance

#### setLogWriter

    public void setLogWriter(PrintWriter pw)

Sets a `PrintWriter` as the current log file.

Parameters:
  `pw` - sets logfile to use this PrintWriter

#### getLogFileName

    public String getLogFileName()

Returns a `String` representing the current log file path.

Returns:
  path and name of log file