Class PGPoolingDataSource
- All Implemented Interfaces:
Wrapper,Referenceable,CommonDataSource,DataSource
- Direct Known Subclasses:
Jdbc3PoolingDataSource,PoolingDataSource
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable StringDeprecated.protected static ConcurrentMap<String,PGPoolingDataSource> Deprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDataSource(String dataSourceName) Deprecated.voidclose()Deprecated.Closes this DataSource, and all the pooled connections, whether in use or not.protected PGConnectionPoolDataSourceDeprecated.Creates the appropriate ConnectionPool to use for this DataSource.Deprecated.Gets a connection from the connection pool.getConnection(@Nullable String user, @Nullable 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 @Nullable PGPoolingDataSourcegetDataSource(String name) Deprecated.@Nullable StringDeprecated.Gets the name of this DataSource.Deprecated.Gets a description of this DataSource.intDeprecated.Gets the number of connections that will be created when this DataSource is initialized.intDeprecated.Gets the maximum number of connections that the pool will allow.Deprecated.Adds custom properties for this DataSource to the properties defined in the superclass.voidDeprecated.Initializes this DataSource.protected booleanDeprecated.booleanisWrapperFor(Class<?> iface) Deprecated.protected voidDeprecated.voidsetDatabaseName(@Nullable String databaseName) Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.voidsetDataSourceName(String dataSourceName) Deprecated.Sets the name of this DataSource.voidsetInitialConnections(int initialConnections) Deprecated.Sets the number of connections that will be created when this DataSource is initialized.voidsetMaxConnections(int maxConnections) Deprecated.Sets the maximum number of connections that the pool will allow.voidsetPassword(@Nullable String password) Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.voidsetPortNumber(int portNumber) Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.voidsetServerName(String serverName) Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.voidDeprecated.Ensures the DataSource properties are not changed after the DataSource has been used.<T> TDeprecated.Methods inherited from class org.postgresql.ds.common.BaseDataSource
createReference, getAdaptiveFetch, getAdaptiveFetchMaximum, getAdaptiveFetchMinimum, getAllowEncodingChanges, getApplicationName, getAssumeMinServerVersion, getAuthenticationPluginClassName, getAutosave, getBinaryTransfer, getBinaryTransferDisable, getBinaryTransferEnable, getCancelSignalTimeout, getCleanupSavepoints, getConnectTimeout, getCurrentSchema, getDatabaseMetadataCacheFields, getDatabaseMetadataCacheFieldsMiB, getDatabaseName, getDefaultRowFetchSize, getDisableColumnSanitiser, getEscapeSyntaxCallMode, getGroupStartupParameters, getGssEncMode, getGssLib, getGssResponseTimeout, getHideUnprivilegedObjects, getHostRecheckSeconds, getJaasApplicationName, getJaasLogin, getKerberosServerName, getLoadBalanceHosts, getLocalSocketAddress, getLoggerFile, getLoggerLevel, getLoginTimeout, getLogServerErrorDetail, getLogUnclosedConnections, getLogWriter, getMaxResultBuffer, getOptions, getParentLogger, getPassword, getPortNumber, getPortNumbers, getPreferQueryMode, getPreparedStatementCacheQueries, getPreparedStatementCacheSizeMiB, getPrepareThreshold, getProperty, getProperty, getProtocolVersion, getQuoteReturningIdentifiers, 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, getSslResponseTimeout, getSslrootcert, getSslRootCert, getSspiServiceClass, getStringType, getTargetServerType, getTcpKeepAlive, getTcpNoDelay, getUnknownLength, getUrl, getURL, getUser, getUseSpNego, getXmlFactoryFactory, initializeFrom, isAllowEncodingChanges, isCleanupSavePoints, isColumnSanitiserDisabled, isDisableColumnSanitiser, isLoadBalanceHosts, isLogUnclosedConnections, isReadOnly, isReWriteBatchedInserts, isSsl, isTcpKeepAlive, readBaseObject, setAdaptiveFetch, setAdaptiveFetchMaximum, setAdaptiveFetchMinimum, setAllowEncodingChanges, setApplicationName, setAssumeMinServerVersion, setAuthenticationPluginClassName, setAutosave, setBinaryTransfer, setBinaryTransferDisable, setBinaryTransferEnable, setCancelSignalTimeout, setCleanupSavepoints, setCleanupSavePoints, setConnectTimeout, setCurrentSchema, setDatabaseMetadataCacheFields, setDatabaseMetadataCacheFieldsMiB, setDefaultRowFetchSize, setDisableColumnSanitiser, setEscapeSyntaxCallMode, setFromReference, setGroupStartupParameters, setGssEncMode, setGssLib, setGssResponseTimeout, setHideUnprivilegedObjects, setHostRecheckSeconds, setJaasApplicationName, setJaasLogin, setKerberosServerName, setLoadBalanceHosts, setLocalSocketAddress, setLoggerFile, setLoggerLevel, setLoginTimeout, setLogServerErrorDetail, setLogUnclosedConnections, setLogWriter, setMaxResultBuffer, setOptions, setPortNumbers, setPreferQueryMode, setPreparedStatementCacheQueries, setPreparedStatementCacheSizeMiB, setPrepareThreshold, setProperty, setProperty, setProtocolVersion, setQuoteReturningIdentifiers, 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, setSslResponseTimeout, setSslrootcert, setSslRootCert, setSspiServiceClass, setStringType, setTargetServerType, setTcpKeepAlive, setTcpNoDelay, setUnknownLength, setUrl, setURL, setUseSpNego, setXmlFactoryFactory, writeBaseObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder, getParentLoggerMethods inherited from interface javax.sql.DataSource
createConnectionBuilder, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
-
Field Details
-
dataSources
Deprecated. -
dataSourceName
Deprecated.
-
-
Constructor Details
-
PGPoolingDataSource
public PGPoolingDataSource()Deprecated.
-
-
Method Details
-
getDataSource
Deprecated. -
getDescription
Deprecated.Gets a description of this DataSource.- Specified by:
getDescriptionin classBaseDataSource- Returns:
- description of this DataSource-ish thing
-
setServerName
Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.- Overrides:
setServerNamein classBaseDataSource- Parameters:
serverName- name of the host the PostgreSQL database is running on- Throws:
IllegalStateException- The Server Name cannot be changed after the DataSource has been used.
-
setDatabaseName
Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.- Overrides:
setDatabaseNamein classBaseDataSource- Parameters:
databaseName- name of the PostgreSQL database- Throws:
IllegalStateException- The Database Name cannot be changed after the DataSource has been used.
-
setUser
Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.- Overrides:
setUserin classBaseDataSource- Parameters:
user- user to connect as by default- Throws:
IllegalStateException- The User cannot be changed after the DataSource has been used.
-
setPassword
Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.- Overrides:
setPasswordin classBaseDataSource- Parameters:
password- password to connect with by default- Throws:
IllegalStateException- The Password cannot be changed after the DataSource has been used.
-
setPortNumber
public void setPortNumber(int portNumber) Deprecated.Ensures the DataSource properties are not changed after the DataSource has been used.- Overrides:
setPortNumberin classBaseDataSource- Parameters:
portNumber- port which the PostgreSQL server is listening on for TCP/IP- Throws:
IllegalStateException- The Port Number cannot be changed after the DataSource has been used.
-
getInitialConnections
public int getInitialConnections()Deprecated.Gets the number of connections that will be created when this DataSource is initialized. If you do not call initialize explicitly, it will be initialized the first time a connection is drawn from it.- Returns:
- number of connections that will be created when this DataSource is initialized
-
setInitialConnections
public void setInitialConnections(int initialConnections) Deprecated.Sets the number of connections that will be created when this DataSource is initialized. If you do not call initialize explicitly, it will be initialized the first time a connection is drawn from it.- Parameters:
initialConnections- number of initial connections- Throws:
IllegalStateException- The Initial Connections cannot be changed after the DataSource has been used.
-
getMaxConnections
public int getMaxConnections()Deprecated.Gets the maximum number of connections that the pool will allow. If a request comes in and this many connections are in use, the request will block until a connection is available. Note that connections for a user other than the default user will not be pooled and don't count against this limit.- Returns:
- The maximum number of pooled connection allowed, or 0 for no maximum.
-
setMaxConnections
public void setMaxConnections(int maxConnections) Deprecated.Sets the maximum number of connections that the pool will allow. If a request comes in and this many connections are in use, the request will block until a connection is available. Note that connections for a user other than the default user will not be pooled and don't count against this limit.- Parameters:
maxConnections- The maximum number of pooled connection to allow, or 0 for no maximum.- Throws:
IllegalStateException- The Maximum Connections cannot be changed after the DataSource has been used.
-
getDataSourceName
Deprecated.Gets the name of this DataSource. This uniquely identifies the DataSource. You cannot use more than one DataSource in the same VM with the same name.- Returns:
- name of this DataSource
-
setDataSourceName
Deprecated.Sets the name of this DataSource. This is required, and uniquely identifies the DataSource. You cannot create or use more than one DataSource in the same VM with the same name.- Parameters:
dataSourceName- datasource name- Throws:
IllegalStateException- The Data Source Name cannot be changed after the DataSource has been used.IllegalArgumentException- Another PoolingDataSource with the same dataSourceName already exists.
-
initialize
Deprecated.Initializes this DataSource. If the initialConnections is greater than zero, that number of connections will be created. After this method is called, the DataSource properties cannot be changed. If you do not call this explicitly, it will be called the first time you get a connection from the DataSource.- Throws:
SQLException- Occurs when the initialConnections is greater than zero, but the DataSource is not able to create enough physical connections.
-
isInitialized
protected boolean isInitialized()Deprecated. -
createConnectionPool
Deprecated.Creates the appropriate ConnectionPool to use for this DataSource.- Returns:
- appropriate ConnectionPool to use for this DataSource
-
getConnection
public Connection getConnection(@Nullable String user, @Nullable String password) throws SQLException Deprecated.Gets a non-pooled connection, unless the user and password are the same as the default values for this connection pool.- Specified by:
getConnectionin interfaceDataSource- Overrides:
getConnectionin classBaseDataSource- Parameters:
user- userpassword- password- Returns:
- A pooled connection.
- Throws:
SQLException- Occurs when no pooled connection is available, and a new physical connection cannot be created.
-
getConnection
Deprecated.Gets a connection from the connection pool.- Specified by:
getConnectionin interfaceDataSource- Overrides:
getConnectionin classBaseDataSource- Returns:
- A pooled connection.
- Throws:
SQLException- Occurs when no pooled connection is available, and a new physical connection cannot be created.
-
close
public void close()Deprecated.Closes this DataSource, and all the pooled connections, whether in use or not. -
removeStoredDataSource
protected void removeStoredDataSource()Deprecated. -
addDataSource
Deprecated. -
getReference
Deprecated.Adds custom properties for this DataSource to the properties defined in the superclass.- Specified by:
getReferencein interfaceReferenceable- Overrides:
getReferencein classBaseDataSource- Throws:
NamingException
-
isWrapperFor
Deprecated.- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
Deprecated.- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-