パッケージ org.postgresql.ds

クラス PGPoolingDataSource

java.lang.Object
org.postgresql.ds.common.BaseDataSource
org.postgresql.ds.PGPoolingDataSource
すべての実装されたインタフェース:
Wrapper, Referenceable, CommonDataSource, DataSource
直系の既知のサブクラス:
Jdbc3PoolingDataSource, PoolingDataSource

@Deprecated public class PGPoolingDataSource extends BaseDataSource implements DataSource
推奨されていません。
Since 42.0.0, instead of this class you should use a fully featured connection pool like HikariCP, vibur-dbcp, commons-dbcp, c3p0, etc.
DataSource which uses connection pooling. Don't use this if your server/middleware vendor provides a connection pooling implementation which interfaces with the PostgreSQL ConnectionPoolDataSource implementation! This class is provided as a convenience, but the JDBC Driver is really not supposed to handle the connection pooling algorithm. Instead, the server or middleware product is supposed to handle the mechanics of connection pooling, and use the PostgreSQL implementation of ConnectionPoolDataSource to provide the connections to pool.

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.

  • フィールド詳細

  • コンストラクタの詳細

    • PGPoolingDataSource

      public PGPoolingDataSource()
      推奨されていません。
  • メソッドの詳細

    • getDataSource

      public static @Nullable PGPoolingDataSource getDataSource(String name)
      推奨されていません。
    • getDescription

      public String getDescription()
      推奨されていません。
      Gets a description of this DataSource.
      定義:
      getDescription クラス内 BaseDataSource
      戻り値:
      description of this DataSource-ish thing
    • setServerName

      public void setServerName(String serverName)
      推奨されていません。
      Ensures the DataSource properties are not changed after the DataSource has been used.
      オーバーライド:
      setServerName クラス内 BaseDataSource
      パラメータ:
      serverName - name of the host the PostgreSQL database is running on
      例外:
      IllegalStateException - The Server Name cannot be changed after the DataSource has been used.
    • setDatabaseName

      public void setDatabaseName(@Nullable String databaseName)
      推奨されていません。
      Ensures the DataSource properties are not changed after the DataSource has been used.
      オーバーライド:
      setDatabaseName クラス内 BaseDataSource
      パラメータ:
      databaseName - name of the PostgreSQL database
      例外:
      IllegalStateException - The Database Name cannot be changed after the DataSource has been used.
    • setUser

      public void setUser(@Nullable String user)
      推奨されていません。
      Ensures the DataSource properties are not changed after the DataSource has been used.
      オーバーライド:
      setUser クラス内 BaseDataSource
      パラメータ:
      user - user to connect as by default
      例外:
      IllegalStateException - The User cannot be changed after the DataSource has been used.
    • setPassword

      public void setPassword(@Nullable String password)
      推奨されていません。
      Ensures the DataSource properties are not changed after the DataSource has been used.
      オーバーライド:
      setPassword クラス内 BaseDataSource
      パラメータ:
      password - password to connect with by default
      例外:
      IllegalStateException - The Password cannot be changed after the DataSource has been used.
    • setPortNumber

      public void setPortNumber(int portNumber)
      推奨されていません。
      Ensures the DataSource properties are not changed after the DataSource has been used.
      オーバーライド:
      setPortNumber クラス内 BaseDataSource
      パラメータ:
      portNumber - port which the PostgreSQL server is listening on for TCP/IP
      例外:
      IllegalStateException - The Port Number cannot be changed after the DataSource has been used.
    • getInitialConnections

      public int getInitialConnections()
      推奨されていません。
      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.
      戻り値:
      number of connections that will be created when this DataSource is initialized
    • setInitialConnections

      public void setInitialConnections(int initialConnections)
      推奨されていません。
      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.
      パラメータ:
      initialConnections - number of initial connections
      例外:
      IllegalStateException - The Initial Connections cannot be changed after the DataSource has been used.
    • getMaxConnections

      public int getMaxConnections()
      推奨されていません。
      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.
      戻り値:
      The maximum number of pooled connection allowed, or 0 for no maximum.
    • setMaxConnections

      public void setMaxConnections(int maxConnections)
      推奨されていません。
      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.
      パラメータ:
      maxConnections - The maximum number of pooled connection to allow, or 0 for no maximum.
      例外:
      IllegalStateException - The Maximum Connections cannot be changed after the DataSource has been used.
    • getDataSourceName

      public @Nullable String getDataSourceName()
      推奨されていません。
      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.
      戻り値:
      name of this DataSource
    • setDataSourceName

      public void setDataSourceName(String dataSourceName)
      推奨されていません。
      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.
      パラメータ:
      dataSourceName - datasource name
      例外:
      IllegalStateException - The Data Source Name cannot be changed after the DataSource has been used.
      IllegalArgumentException - Another PoolingDataSource with the same dataSourceName already exists.
    • initialize

      public void initialize() throws SQLException
      推奨されていません。
      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.
      例外:
      SQLException - Occurs when the initialConnections is greater than zero, but the DataSource is not able to create enough physical connections.
    • isInitialized

      protected boolean isInitialized()
      推奨されていません。
    • createConnectionPool

      protected PGConnectionPoolDataSource createConnectionPool()
      推奨されていません。
      Creates the appropriate ConnectionPool to use for this DataSource.
      戻り値:
      appropriate ConnectionPool to use for this DataSource
    • getConnection

      public Connection getConnection(@Nullable String user, @Nullable String password) throws SQLException
      推奨されていません。
      Gets a non-pooled connection, unless the user and password are the same as the default values for this connection pool.
      定義:
      getConnection インタフェース内 DataSource
      オーバーライド:
      getConnection クラス内 BaseDataSource
      パラメータ:
      user - user
      password - password
      戻り値:
      A pooled connection.
      例外:
      SQLException - Occurs when no pooled connection is available, and a new physical connection cannot be created.
    • getConnection

      public Connection getConnection() throws SQLException
      推奨されていません。
      Gets a connection from the connection pool.
      定義:
      getConnection インタフェース内 DataSource
      オーバーライド:
      getConnection クラス内 BaseDataSource
      戻り値:
      A pooled connection.
      例外:
      SQLException - Occurs when no pooled connection is available, and a new physical connection cannot be created.
    • close

      public void close()
      推奨されていません。
      Closes this DataSource, and all the pooled connections, whether in use or not.
    • removeStoredDataSource

      protected void removeStoredDataSource()
      推奨されていません。
    • addDataSource

      protected void addDataSource(String dataSourceName)
      推奨されていません。
    • getReference

      public Reference getReference() throws NamingException
      推奨されていません。
      Adds custom properties for this DataSource to the properties defined in the superclass.
      定義:
      getReference インタフェース内 Referenceable
      オーバーライド:
      getReference クラス内 BaseDataSource
      例外:
      NamingException
    • isWrapperFor

      public boolean isWrapperFor(Class<?> iface) throws SQLException
      推奨されていません。
      定義:
      isWrapperFor インタフェース内 Wrapper
      例外:
      SQLException
    • unwrap

      public <T> T unwrap(Class<T> iface) throws SQLException
      推奨されていません。
      定義:
      unwrap インタフェース内 Wrapper
      例外:
      SQLException