@Deprecated public class PGPoolingDataSource extends BaseDataSource implements javax.sql.DataSource
If you're sure you want to use this, then you must set the properties dataSourceName, databaseName, user, and password (if required for the user). The settings for serverName, portNumber, initialConnections, and maxConnections are optional. Note that only connections for the default user will be pooled! Connections for other users will be normal non-pooled connections, and will not count against the maximum pool size limit.
If you put this DataSource in JNDI, and access it from different JVMs (or otherwise load this class from different ClassLoaders), you'll end up with one pool per ClassLoader or VM. This is another area where a server-specific implementation may provide advanced features, such as using a single pool across all VMs in a cluster.
This implementation supports JDK 1.5 and higher.
Modifier and Type | Field and Description |
---|---|
private java.util.Stack<javax.sql.PooledConnection> |
available
Deprecated.
|
private javax.sql.ConnectionEventListener |
connectionEventListener
Deprecated.
Notified when a pooled connection is closed, or a fatal error occurs on a pooled connection.
|
protected java.lang.String |
dataSourceName
Deprecated.
|
protected static java.util.concurrent.ConcurrentMap<java.lang.String,PGPoolingDataSource> |
dataSources
Deprecated.
|
private int |
initialConnections
Deprecated.
|
private boolean |
initialized
Deprecated.
|
private java.lang.Object |
lock
Deprecated.
|
private int |
maxConnections
Deprecated.
|
private PGConnectionPoolDataSource |
source
Deprecated.
|
private java.util.Stack<javax.sql.PooledConnection> |
used
Deprecated.
|
Constructor and Description |
---|
PGPoolingDataSource()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addDataSource(java.lang.String dataSourceName)
Deprecated.
|
void |
close()
Deprecated.
Closes this DataSource, and all the pooled connections, whether in use or not.
|
protected PGConnectionPoolDataSource |
createConnectionPool()
Deprecated.
Creates the appropriate ConnectionPool to use for this DataSource.
|
java.sql.Connection |
getConnection()
Deprecated.
Gets a connection from the connection pool.
|
java.sql.Connection |
getConnection(java.lang.String user,
java.lang.String password)
Deprecated.
Gets a non-pooled connection, unless the user and password are the same as the default
values for this connection pool.
|
static PGPoolingDataSource |
getDataSource(java.lang.String name)
Deprecated.
|
java.lang.String |
getDataSourceName()
Deprecated.
Gets the name of this DataSource.
|
java.lang.String |
getDescription()
Deprecated.
Gets a description of this DataSource.
|
int |
getInitialConnections()
Deprecated.
Gets the number of connections that will be created when this DataSource is initialized.
|
int |
getMaxConnections()
Deprecated.
Gets the maximum number of connections that the pool will allow.
|
private java.sql.Connection |
getPooledConnection()
Deprecated.
Gets a connection from the pool.
|
javax.naming.Reference |
getReference()
Deprecated.
Adds custom properties for this DataSource to the properties defined in the superclass.
|
void |
initialize()
Deprecated.
Initializes this DataSource.
|
protected boolean |
isInitialized()
Deprecated.
|
boolean |
isWrapperFor(java.lang.Class<?> iface)
Deprecated.
|
protected void |
removeStoredDataSource()
Deprecated.
|
void |
setDatabaseName(java.lang.String databaseName)
Deprecated.
Ensures the DataSource properties are not changed after the DataSource has been used.
|
void |
setDataSourceName(java.lang.String dataSourceName)
Deprecated.
Sets the name of this DataSource.
|
void |
setInitialConnections(int initialConnections)
Deprecated.
Sets the number of connections that will be created when this DataSource is initialized.
|
void |
setMaxConnections(int maxConnections)
Deprecated.
Sets the maximum number of connections that the pool will allow.
|
void |
setPassword(java.lang.String password)
Deprecated.
Ensures the DataSource properties are not changed after the DataSource has been used.
|
void |
setPortNumber(int portNumber)
Deprecated.
Ensures the DataSource properties are not changed after the DataSource has been used.
|
void |
setServerName(java.lang.String serverName)
Deprecated.
Ensures the DataSource properties are not changed after the DataSource has been used.
|
void |
setUser(java.lang.String user)
Deprecated.
Ensures the DataSource properties are not changed after the DataSource has been used.
|
<T> T |
unwrap(java.lang.Class<T> iface)
Deprecated.
|
createReference, getAllowEncodingChanges, getApplicationName, getAssumeMinServerVersion, getAutosave, getBinaryTransfer, getBinaryTransferDisable, getBinaryTransferEnable, getCancelSignalTimeout, getCleanupSavepoints, getConnectTimeout, getCurrentSchema, getDatabaseMetadataCacheFields, getDatabaseMetadataCacheFieldsMiB, getDatabaseName, getDefaultRowFetchSize, getDisableColumnSanitiser, getEscapeSyntaxCallMode, getGssLib, getHideUnprivilegedObjects, getHostRecheckSeconds, getJaasApplicationName, getJaasLogin, getKerberosServerName, getLoadBalanceHosts, getLoggerFile, getLoggerLevel, getLoginTimeout, getLogServerErrorDetail, getLogUnclosedConnections, getLogWriter, getMaxResultBuffer, getOptions, getParentLogger, getPassword, getPortNumber, getPortNumbers, getPreferQueryMode, getPreparedStatementCacheQueries, getPreparedStatementCacheSizeMiB, getPrepareThreshold, getProperty, getProperty, getProtocolVersion, getReadOnly, getReadOnlyMode, getReceiveBufferSize, getRecvBufferSize, getReplication, getReWriteBatchedInserts, getSendBufferSize, getServerName, getServerNames, getSocketFactory, getSocketFactoryArg, getSocketTimeout, getSsl, getSslcert, getSslCert, getSslfactory, getSslfactoryarg, getSslFactoryArg, getSslhostnameverifier, getSslHostnameVerifier, getSslkey, getSslKey, getSslmode, getSslMode, getSslpassword, getSslPassword, getSslpasswordcallback, getSslPasswordCallback, getSslrootcert, getSslRootCert, getSspiServiceClass, getStringType, getTargetServerType, getTcpKeepAlive, getUnknownLength, getUrl, getURL, getUser, getUseSpNego, getXmlFactoryFactory, initializeFrom, isAllowEncodingChanges, isCleanupSavePoints, isColumnSanitiserDisabled, isDisableColumnSanitiser, isLoadBalanceHosts, isLogUnclosedConnections, isReadOnly, isReWriteBatchedInserts, isSsl, isTcpKeepAlive, readBaseObject, setAllowEncodingChanges, setApplicationName, setAssumeMinServerVersion, setAutosave, setBinaryTransfer, setBinaryTransferDisable, setBinaryTransferEnable, setCancelSignalTimeout, setCleanupSavepoints, setCleanupSavePoints, setConnectTimeout, setCurrentSchema, setDatabaseMetadataCacheFields, setDatabaseMetadataCacheFieldsMiB, setDefaultRowFetchSize, setDisableColumnSanitiser, setEscapeSyntaxCallMode, setFromReference, setGssLib, setHideUnprivilegedObjects, setHostRecheckSeconds, setJaasApplicationName, setJaasLogin, setKerberosServerName, setLoadBalanceHosts, setLoggerFile, setLoggerLevel, setLoginTimeout, setLogServerErrorDetail, setLogUnclosedConnections, setLogWriter, setMaxResultBuffer, setOptions, setPortNumbers, setPreferQueryMode, setPreparedStatementCacheQueries, setPreparedStatementCacheSizeMiB, setPrepareThreshold, setProperty, setProperty, setProtocolVersion, setReadOnly, setReadOnlyMode, setReceiveBufferSize, setRecvBufferSize, setReplication, setReWriteBatchedInserts, setSendBufferSize, setServerNames, setSocketFactory, setSocketFactoryArg, setSocketTimeout, setSsl, setSslcert, setSslCert, setSslfactory, setSslfactoryarg, setSslFactoryArg, setSslhostnameverifier, setSslHostnameVerifier, setSslkey, setSslKey, setSslmode, setSslMode, setSslpassword, setSslPassword, setSslpasswordcallback, setSslPasswordCallback, setSslrootcert, setSslRootCert, setSspiServiceClass, setStringType, setTargetServerType, setTcpKeepAlive, setUnknownLength, setUrl, setURL, setUseSpNego, setXmlFactoryFactory, writeBaseObject
protected static java.util.concurrent.ConcurrentMap<java.lang.String,PGPoolingDataSource> dataSources
protected java.lang.String dataSourceName
private int initialConnections
private int maxConnections
private boolean initialized
private java.util.Stack<javax.sql.PooledConnection> available
private java.util.Stack<javax.sql.PooledConnection> used
private java.lang.Object lock
private PGConnectionPoolDataSource source
private javax.sql.ConnectionEventListener connectionEventListener
public static PGPoolingDataSource getDataSource(java.lang.String name)
public java.lang.String getDescription()
getDescription
in class BaseDataSource
public void setServerName(java.lang.String serverName)
setServerName
in class BaseDataSource
serverName
- name of the host the PostgreSQL database is running onjava.lang.IllegalStateException
- The Server Name cannot be changed after the DataSource has been
used.public void setDatabaseName(java.lang.String databaseName)
setDatabaseName
in class BaseDataSource
databaseName
- name of the PostgreSQL databasejava.lang.IllegalStateException
- The Database Name cannot be changed after the DataSource has been
used.public void setUser(java.lang.String user)
setUser
in class BaseDataSource
user
- user to connect as by defaultjava.lang.IllegalStateException
- The User cannot be changed after the DataSource has been used.public void setPassword(java.lang.String password)
setPassword
in class BaseDataSource
password
- password to connect with by defaultjava.lang.IllegalStateException
- The Password cannot be changed after the DataSource has been
used.public void setPortNumber(int portNumber)
setPortNumber
in class BaseDataSource
portNumber
- port which the PostgreSQL server is listening on for TCP/IPjava.lang.IllegalStateException
- The Port Number cannot be changed after the DataSource has been
used.public int getInitialConnections()
public void setInitialConnections(int initialConnections)
initialConnections
- number of initial connectionsjava.lang.IllegalStateException
- The Initial Connections cannot be changed after the DataSource
has been used.public int getMaxConnections()
public void setMaxConnections(int maxConnections)
maxConnections
- The maximum number of pooled connection to allow, or 0 for no maximum.java.lang.IllegalStateException
- The Maximum Connections cannot be changed after the DataSource
has been used.public java.lang.String getDataSourceName()
public void setDataSourceName(java.lang.String dataSourceName)
dataSourceName
- datasource namejava.lang.IllegalStateException
- The Data Source Name cannot be changed after the DataSource has
been used.java.lang.IllegalArgumentException
- Another PoolingDataSource with the same dataSourceName already
exists.public void initialize() throws java.sql.SQLException
java.sql.SQLException
- Occurs when the initialConnections is greater than zero, but the
DataSource is not able to create enough physical connections.protected boolean isInitialized()
protected PGConnectionPoolDataSource createConnectionPool()
public java.sql.Connection getConnection(java.lang.String user, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
getConnection
in class BaseDataSource
user
- userpassword
- passwordjava.sql.SQLException
- Occurs when no pooled connection is available, and a new physical
connection cannot be created.public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
getConnection
in class BaseDataSource
java.sql.SQLException
- Occurs when no pooled connection is available, and a new physical
connection cannot be created.public void close()
protected void removeStoredDataSource()
protected void addDataSource(java.lang.String dataSourceName)
private java.sql.Connection getPooledConnection() throws java.sql.SQLException
java.sql.SQLException
public javax.naming.Reference getReference() throws javax.naming.NamingException
getReference
in interface javax.naming.Referenceable
getReference
in class BaseDataSource
javax.naming.NamingException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException