public abstract class AbstractJdbc23PoolingDataSource extends BaseDataSource
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.3 and higher.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
dataSourceName |
protected static java.util.Map |
dataSources |
| Constructor and Description |
|---|
AbstractJdbc23PoolingDataSource() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addDataSource(java.lang.String dataSourceName) |
void |
close()
Closes this DataSource, and all the pooled connections, whether in use or not.
|
protected PGConnectionPoolDataSource |
createConnectionPool()
Creates the appropriate ConnectionPool to use for this DataSource.
|
java.sql.Connection |
getConnection()
Gets a connection from the connection pool.
|
java.sql.Connection |
getConnection(java.lang.String user,
java.lang.String password)
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) |
java.lang.String |
getDataSourceName()
Gets the name of this DataSource.
|
java.lang.String |
getDescription()
Gets a description of this DataSource.
|
int |
getInitialConnections()
Gets the number of connections that will be created when this DataSource
is initialized.
|
int |
getMaxConnections()
Gets the maximum number of connections that the pool will allow.
|
javax.naming.Reference |
getReference()
Adds custom properties for this DataSource to the properties defined in
the superclass.
|
void |
initialize()
Initializes this DataSource.
|
protected boolean |
isInitialized() |
protected void |
removeStoredDataSource() |
void |
setDatabaseName(java.lang.String databaseName)
Ensures the DataSource properties are not changed after the DataSource has
been used.
|
void |
setDataSourceName(java.lang.String dataSourceName)
Sets the name of this DataSource.
|
void |
setInitialConnections(int initialConnections)
Sets the number of connections that will be created when this DataSource
is initialized.
|
void |
setMaxConnections(int maxConnections)
Sets the maximum number of connections that the pool will allow.
|
void |
setPassword(java.lang.String password)
Ensures the DataSource properties are not changed after the DataSource has
been used.
|
void |
setPortNumber(int portNumber)
Ensures the DataSource properties are not changed after the DataSource has
been used.
|
void |
setServerName(java.lang.String serverName)
Ensures the DataSource properties are not changed after the DataSource has
been used.
|
void |
setUser(java.lang.String user)
Ensures the DataSource properties are not changed after the DataSource has
been used.
|
createReference, getApplicationName, getCompatible, getDatabaseName, getLoginTimeout, getLogLevel, getLogWriter, getPassword, getPortNumber, getPrepareThreshold, getProtocolVersion, getServerName, getSocketTimeout, getSsl, getSslfactory, getTcpKeepAlive, getUnknownLength, getUser, initializeFrom, readBaseObject, setApplicationName, setCompatible, setLoginTimeout, setLogLevel, setLogWriter, setPrepareThreshold, setProtocolVersion, setSocketTimeout, setSsl, setSslfactory, setTcpKeepAlive, setUnknownLength, writeBaseObjectprotected static java.util.Map dataSources
protected java.lang.String dataSourceName
public static PGPoolingDataSource getDataSource(java.lang.String name)
public java.lang.String getDescription()
getDescription in class BaseDataSourcepublic void setServerName(java.lang.String serverName)
setServerName in class BaseDataSourcejava.lang.IllegalStateException - The Server Name cannot be changed after the DataSource has been
used.public void setDatabaseName(java.lang.String databaseName)
setDatabaseName in class BaseDataSourcejava.lang.IllegalStateException - The Database Name cannot be changed after the DataSource has been
used.public void setUser(java.lang.String user)
setUser in class BaseDataSourcejava.lang.IllegalStateException - The User cannot be changed after the DataSource has been
used.public void setPassword(java.lang.String password)
setPassword in class BaseDataSourcejava.lang.IllegalStateException - The Password cannot be changed after the DataSource has been
used.public void setPortNumber(int portNumber)
setPortNumber in class BaseDataSourcejava.lang.IllegalStateException - The Port Number cannot be changed after the DataSource has been
used.public int getInitialConnections()
public void setInitialConnections(int initialConnections)
java.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)
java.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 class BaseDataSourcejava.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 class BaseDataSourcejava.sql.SQLException - Occurs when no pooled connection is available, and a new physical
connection cannot be created.public void close()
protected void removeStoredDataSource()
protected abstract void addDataSource(java.lang.String dataSourceName)
public javax.naming.Reference getReference()
throws javax.naming.NamingException
getReference in interface javax.naming.ReferenceablegetReference in class BaseDataSourcejavax.naming.NamingException