Class JdbcUtils.DataSourcePool

  • Enclosing class:
    JdbcUtils

    static class JdbcUtils.DataSourcePool
    extends java.lang.Object
    Ensures that if two data sources have the same definition, they will use the same object.

    This in turn makes it easier to cache SqlDialect objects. Otherwise, each time we see a new data source, we have to open a connection to find out what database product and version it is.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.google.common.cache.LoadingCache<java.util.List<java.lang.String>,​org.apache.commons.dbcp2.BasicDataSource> cache  
      static JdbcUtils.DataSourcePool INSTANCE  
    • Constructor Summary

      Constructors 
      Constructor Description
      DataSourcePool()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static org.apache.commons.dbcp2.BasicDataSource dataSource​(java.util.List<java.lang.String> key)  
      javax.sql.DataSource get​(java.lang.String url, java.lang.String driverClassName, java.lang.String username, java.lang.String password)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cache

        private final com.google.common.cache.LoadingCache<java.util.List<java.lang.String>,​org.apache.commons.dbcp2.BasicDataSource> cache
    • Constructor Detail

      • DataSourcePool

        DataSourcePool()
    • Method Detail

      • dataSource

        @Nonnull
        private static org.apache.commons.dbcp2.BasicDataSource dataSource​(@Nonnull
                                                                           java.util.List<java.lang.String> key)
      • get

        public javax.sql.DataSource get​(java.lang.String url,
                                        java.lang.String driverClassName,
                                        java.lang.String username,
                                        java.lang.String password)