Package virtuoso.jdbc4

## Class VirtuosoConnectionPoolDataSource

- java.lang.Object
- - virtuoso.jdbc4.VirtuosoDataSource
  - - virtuoso.jdbc4.VirtuosoConnectionPoolDataSource

All Implemented Interfaces:
  `java.util.EventListener`, `javax.sql.CommonDataSource`, `javax.sql.ConnectionEventListener`, `javax.sql.ConnectionPoolDataSource`

Direct Known Subclasses:
  `VirtuosoXADataSource`

    public class VirtuosoConnectionPoolDataSource
    extends VirtuosoDataSource
    implements javax.sql.ConnectionPoolDataSource, javax.sql.ConnectionEventListener

See Also:
  Serialized Form

### Field Summary

Fields
`int` `initialPoolSize`
`int` `maxIdleTime`
`int` `maxPoolSize`
`int` `maxStatements`
`int` `minPoolSize`
`protected static java.lang.String` `n_initialPoolSize`
`protected static java.lang.String` `n_maxIdleTime`
`protected static java.lang.String` `n_maxPoolSize`
`protected static java.lang.String` `n_maxStatements`
`protected static java.lang.String` `n_minPoolSize`
`protected static java.lang.String` `n_propertyCycle`
`int` `propertyCycle`

### Fields inherited from class virtuoso.jdbc4.VirtuosoDataSource

`certificate, charSet, databaseName, dataSourceName, delegate, description, fbs, keystorepass, keystorepath, log_enable, logFileName, loginTimeout, logWriter, password, portNumber, provider, pstmtpoolsize, pwdclear, recvbs, roundrobin, sendbs, serverName, ssl, truststorepass, truststorepath, usepstmtpool, user`

### Constructor Summary

Constructors
`VirtuosoConnectionPoolDataSource​()`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `addProperties​(javax.naming.Reference ref)`
`protected void` `checkPool​()`
`protected void` `checkPropQueue​()`
`void` `close​()` Physically close all the pooled connections in the cache and free all the resources
`void` `connectionClosed​(javax.sql.ConnectionEvent event)` Invoked when the application calls close() on its representation of the connection.
`void` `connectionErrorOccurred​(javax.sql.ConnectionEvent event)` Invoked when a fatal connection error occurs, just before an SQLException is thrown to the application.
`void` `fill​()` Fills the cache with PooledConnections for later use.
`VirtuosoPoolStatistic` `get_statistics​()` Return the cache statistics for the VirtuosoConnectionPoolDataSource
`VirtuosoPoolStatistic[]` `getAll_statistics​()` Return an array of the cache statistics for the all created VirtuosoConnectionPoolDataSources
`java.sql.Connection` `getConnection​()` Attempt to get a database connection from the pool or to establish a database connection .
`java.sql.Connection` `getConnection​(java.lang.String user, java.lang.String password)` Attempt to get a database connection from the pool or to establish a database connection .
`int` `getInitialPoolSize​()` Get the number of physical connections the pool will contain when it is created
`int` `getMaxIdleTime​()` Get the number of seconds that a physical connection will remain unused in the pool before the connection is closed.
`int` `getMaxPoolSize​()` Get the maximum number of physical connections the pool will be able contain.
`int` `getMaxStatements​()` Get the total number of statements that the pool will keep open.
`int` `getMinPoolSize​()` Get the minimum number of physical connections the pool will keep available at all times.
`javax.sql.PooledConnection` `getPooledConnection​()` Attempt to establish a database connection.
`javax.sql.PooledConnection` `getPooledConnection​(java.lang.String _user, java.lang.String _password)` Attempts to establish a physical database connection that can be used as a pooled connection.
`int` `getPropertyCycle​()` Get the interval, in seconds, that the pool will wait before enforcing the current policy defined by the values of the above connection pool properties
`javax.naming.Reference` `getReference​()`
`void` `setInitialPoolSize​(int parm)` Set the number of physical connections the pool should contain when it is created
`void` `setMaxIdleTime​(int parm)` Set the number of seconds that a physical connection should remain unused in the pool before the connection is closed.
`void` `setMaxPoolSize​(int parm)` Set the maximum number of physical conections that the pool should contain.
`void` `setMaxStatements​(int parm)` Set the total number of statements that the pool should keep open.
`void` `setMinPoolSize​(int parm)` Set the number of physical connections the pool should keep available at all times.
`void` `setPropertyCycle​(int parm)` Set the interval, in seconds, that the pool should wait before enforcing the current policy defined by the values of the above connection pool properties

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

`createShardingKeyBuilder, getParentLogger`

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

`createPooledConnectionBuilder, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter`

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

`createConnectionBuilder`

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

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

### Methods inherited from class virtuoso.jdbc4.VirtuosoDataSource

`create_url, create_url_key, createConnProperties, getCertificate, getCharset, getDatabaseName, getDataSourceName, getDelgate, getDescription, getFbs, getKeystorepass, getKeystorepath, getLog_Enable, getLogFileName, getLoginTimeout, getLogWriter, getParentLogger, getPassword, getPortNumber, getProvider, getPstmtpoolsize, getPwdClear, getRecvbs, getRoundrobin, getSendbs, getServerName, getSsl, getTruststorepass, getTruststorepath, getUsepstmtpool, getUser, isWrapperFor, setCertificate, setCharset, setDatabaseName, setDataSourceName, setDelegate, setDescription, setFbs, setKeystorepass, setKeystorepath, setLog_Enable, setLogFileName, setLoginTimeout, setLogWriter, setPassword, setPortNumber, setProvider, setPstmtpoolsize, setPwdClear, setRecvbs, setRoundrobin, setSendbs, setServerName, setSsl, setTruststorepass, setTruststorepath, setUsepstmtpool, setUser, unwrap`

### Field Detail

#### n_initialPoolSize

    protected static final java.lang.String n_initialPoolSize

See Also:
  Constant Field Values

#### n_minPoolSize

    protected static final java.lang.String n_minPoolSize

See Also:
  Constant Field Values

#### n_maxPoolSize

    protected static final java.lang.String n_maxPoolSize

See Also:
  Constant Field Values

#### n_maxIdleTime

    protected static final java.lang.String n_maxIdleTime

See Also:
  Constant Field Values

#### n_propertyCycle

    protected static final java.lang.String n_propertyCycle

See Also:
  Constant Field Values

#### n_maxStatements

    protected static final java.lang.String n_maxStatements

See Also:
  Constant Field Values

#### initialPoolSize

    public int initialPoolSize

#### minPoolSize

    public volatile int minPoolSize

#### maxPoolSize

    public volatile int maxPoolSize

#### maxIdleTime

    public volatile int maxIdleTime

#### propertyCycle

    public volatile int propertyCycle

#### maxStatements

    public volatile int maxStatements

### Constructor Detail

#### VirtuosoConnectionPoolDataSource

    public VirtuosoConnectionPoolDataSource​()

### Method Detail

#### checkPool

    protected void checkPool​()

#### checkPropQueue

    protected void checkPropQueue​()

#### get_statistics

    public VirtuosoPoolStatistic get_statistics​()

Return the cache statistics for the VirtuosoConnectionPoolDataSource

Returns:
  the cache statistics

#### getAll_statistics

    public VirtuosoPoolStatistic[] getAll_statistics​()

Return an array of the cache statistics for the all created VirtuosoConnectionPoolDataSources

Returns:
  the array of cache statistics

#### close

    public void close​()
               throws java.sql.SQLException

Physically close all the pooled connections in the cache and free all the resources

Throws:
  `java.sql.SQLException` - if a database-access error occurs

#### connectionClosed

    public void connectionClosed​(javax.sql.ConnectionEvent event)

Invoked when the application calls close() on its representation of the connection.

Specified by:
  `connectionClosed` in interface `javax.sql.ConnectionEventListener`
Parameters:
  `event` - an event object describing the source of the event

#### connectionErrorOccurred

    public void connectionErrorOccurred​(javax.sql.ConnectionEvent event)

Invoked when a fatal connection error occurs, just before an SQLException is thrown to the application.

Specified by:
  `connectionErrorOccurred` in interface `javax.sql.ConnectionEventListener`
Parameters:
  `event` - an event object describing the source of the event

#### addProperties

    protected void addProperties​(javax.naming.Reference ref)

Overrides:
  `addProperties` in class `VirtuosoDataSource`

#### getReference

    public javax.naming.Reference getReference​()
                                        throws javax.naming.NamingException

Overrides:
  `getReference` in class `VirtuosoDataSource`
Throws:
  `javax.naming.NamingException`

#### fill

    public void fill​()
              throws java.sql.SQLException

Fills the cache with PooledConnections for later use. Ignored if the MinPoolSize is 0. It is usually called when the OPLConnectionPoolDataSource is created via JNDI calls.

Throws:
  `java.sql.SQLException` - if a error occurs

#### getConnection

    public java.sql.Connection getConnection​()
                                      throws java.sql.SQLException

Attempt to get a database connection from the pool or to establish a database connection .

Overrides:
  `getConnection` in class `VirtuosoDataSource`
Returns:
  a Connection to the database
Throws:
  `java.sql.SQLException` - if a database-access error occurs

#### getConnection

    public java.sql.Connection getConnection​(java.lang.String user,
                                             java.lang.String password)
                                      throws java.sql.SQLException

Attempt to get a database connection from the pool or to establish a database connection .

Overrides:
  `getConnection` in class `VirtuosoDataSource`
Parameters:
  `user` - the database user on whose behalf the Connection is being made
  `password` - the user's password
Returns:
  a Connection to the database
Throws:
  `java.sql.SQLException` - if a database-access error occurs

#### getPooledConnection

    public javax.sql.PooledConnection getPooledConnection​()
                                                   throws java.sql.SQLException

Attempt to establish a database connection.

Specified by:
  `getPooledConnection` in interface `javax.sql.ConnectionPoolDataSource`
Returns:
  a PooledConnection to the database
Throws:
  `java.sql.SQLException` - if a database-access error occurs

#### getPooledConnection

    public javax.sql.PooledConnection getPooledConnection​(java.lang.String _user,
                                                          java.lang.String _password)
                                                   throws java.sql.SQLException

Attempts to establish a physical database connection that can be used as a pooled connection.

Specified by:
  `getPooledConnection` in interface `javax.sql.ConnectionPoolDataSource`
Parameters:
  `_user` - the database user on whose behalf the Connection is being made
  `_password` - the user's password
Returns:
  a PooledConnection to the database
Throws:
  `java.sql.SQLException` - if a database-access error occurs

#### getMinPoolSize

    public int getMinPoolSize​()

Get the minimum number of physical connections the pool will keep available at all times. Zero ( 0 ) indicates that connections will be created as needed.

Returns:
  the minimum number of physical connections

#### setMinPoolSize

    public void setMinPoolSize​(int parm)
                        throws java.sql.SQLException

Set the number of physical connections the pool should keep available at all times. Zero ( 0 ) indicates that connections should be created as needed The default value is 0 .

Parameters:
  `parm` - a minimum number of physical connections
Throws:
  `java.sql.SQLException` - if an error occurs

#### getMaxPoolSize

    public int getMaxPoolSize​()

Get the maximum number of physical connections the pool will be able contain. Zero ( 0 ) indicates no maximum size.

Returns:
  the maximum number of physical connections

#### setMaxPoolSize

    public void setMaxPoolSize​(int parm)
                        throws java.sql.SQLException

Set the maximum number of physical conections that the pool should contain. Zero ( 0 ) indicates no maximum size. The default value is 0 .

Parameters:
  `parm` - a maximum number of physical connections
Throws:
  `java.sql.SQLException` - if an error occurs

#### getInitialPoolSize

    public int getInitialPoolSize​()

Get the number of physical connections the pool will contain when it is created

Returns:
  the number of physical connections

#### setInitialPoolSize

    public void setInitialPoolSize​(int parm)
                            throws java.sql.SQLException

Set the number of physical connections the pool should contain when it is created

Parameters:
  `parm` - a number of physical connections
Throws:
  `java.sql.SQLException` - if an error occurs

#### getMaxIdleTime

    public int getMaxIdleTime​()

Get the number of seconds that a physical connection will remain unused in the pool before the connection is closed. Zero ( 0 ) indicates no limit.

Returns:
  the number of seconds

#### setMaxIdleTime

    public void setMaxIdleTime​(int parm)
                        throws java.sql.SQLException

Set the number of seconds that a physical connection should remain unused in the pool before the connection is closed. Zero ( 0 ) indicates no limit.

Parameters:
  `parm` - a number of seconds
Throws:
  `java.sql.SQLException` - if an error occurs

#### getPropertyCycle

    public int getPropertyCycle​()

Get the interval, in seconds, that the pool will wait before enforcing the current policy defined by the values of the above connection pool properties

Returns:
  the interval (in seconds)

#### setPropertyCycle

    public void setPropertyCycle​(int parm)

Set the interval, in seconds, that the pool should wait before enforcing the current policy defined by the values of the above connection pool properties

Parameters:
  `parm` - an interval (in seconds)

#### getMaxStatements

    public int getMaxStatements​()

Get the total number of statements that the pool will keep open. Zero ( 0 ) indicates that caching of statements is disabled.

Returns:
  the total number of statements

#### setMaxStatements

    public void setMaxStatements​(int parm)
                          throws java.sql.SQLException

Set the total number of statements that the pool should keep open. Zero ( 0 ) indicates that caching of statements is disabled.

Parameters:
  `parm` - a total number of statements
Throws:
  `java.sql.SQLException` - if an error occurs