Interface DataSourcePool

All Superinterfaces:
CommonDataSource, DataSource, Wrapper

public interface DataSourcePool extends DataSource
DataSource pool API.


    DataSourcePool pool = DataSourcePool.builder()
      .setName("test")
      .setUrl("jdbc:h2:mem:tests")
      .setUsername("sa")
      .setPassword("")
      .build();

   Connection connection = pool.getConnection();

 
  • Method Details

    • builder

      static DataSourceBuilder builder()
      Return a builder for the DataSourcePool.
      
      
          DataSourcePool pool = DataSourcePool.builder()
            .setName("test")
            .setUrl("jdbc:h2:mem:tests")
            .setUsername("sa")
            .setPassword("")
            .build();
      
         Connection connection = pool.getConnection();
      
       
    • name

      String name()
      Return the dataSource name.
    • size

      int size()
      Return the current size of the pool. This includes both busy and idle connections.
    • isAutoCommit

      boolean isAutoCommit()
      Return true if the pool defaults to using autocommit.
    • isOnline

      boolean isOnline()
      Return true if the DataSource is online.

      Effectively the same as (synonym for) isDataSourceUp().

    • isDataSourceUp

      boolean isDataSourceUp()
      Returns false when the dataSource is down.

      Effectively the same as (synonym for) isOnline().

    • online

      void online() throws SQLException
      Bring the DataSource online ensuring min connections and start heart beat checking.
      Throws:
      SQLException
    • offline

      void offline()
      Take the DataSource offline closing all connections and stopping heart beat checking.
    • shutdown

      void shutdown()
      Shutdown the pool.

      This will close all the free connections, and then go into a wait loop, waiting for the busy connections to be freed.

      This is functionally the same as offline() but generally we expect to only shut down the pool once whereas we can expect to make many calls to offline() and online().

    • status

      PoolStatus status(boolean reset)
      Return the current status of the connection pool.

      With reset true, the counters are reset.

    • dataSourceDownReason

      SQLException dataSourceDownReason()
      Returns the reason, why the dataSource is down.
    • setMaxSize

      void setMaxSize(int max)
      Set a new maximum size.

      The pool will apply the new maximum and not require a restart.