Class DistributedDataSource

  • All Implemented Interfaces:
    java.lang.Iterable<javax.sql.DataSource>, java.sql.Wrapper, javax.sql.CommonDataSource, javax.sql.DataSource, Closeable

    public class DistributedDataSource
    extends DecoratingDataSource
    implements java.lang.Iterable<javax.sql.DataSource>
    A virtual datasource that contains many physical datasources.
    Author:
    Pinaki Poddar
    • Constructor Detail

      • DistributedDataSource

        public DistributedDataSource​(java.util.List<javax.sql.DataSource> dataSources)
    • Method Detail

      • addDataSource

        public void addDataSource​(javax.sql.DataSource ds)
      • iterator

        public java.util.Iterator<javax.sql.DataSource> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<javax.sql.DataSource>
      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException
        Specified by:
        getConnection in interface javax.sql.DataSource
        Overrides:
        getConnection in class DecoratingDataSource
        Throws:
        java.sql.SQLException
      • getConnection

        public java.sql.Connection getConnection​(java.lang.String username,
                                                 java.lang.String password)
                                          throws java.sql.SQLException
        Specified by:
        getConnection in interface javax.sql.DataSource
        Overrides:
        getConnection in class DecoratingDataSource
        Throws:
        java.sql.SQLException
      • getLogWriter

        public java.io.PrintWriter getLogWriter()
                                         throws java.sql.SQLException
        Specified by:
        getLogWriter in interface javax.sql.CommonDataSource
        Specified by:
        getLogWriter in interface javax.sql.DataSource
        Overrides:
        getLogWriter in class DelegatingDataSource
        Throws:
        java.sql.SQLException
      • getLoginTimeout

        public int getLoginTimeout()
                            throws java.sql.SQLException
        Specified by:
        getLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        getLoginTimeout in interface javax.sql.DataSource
        Overrides:
        getLoginTimeout in class DelegatingDataSource
        Throws:
        java.sql.SQLException
      • setLogWriter

        public void setLogWriter​(java.io.PrintWriter out)
                          throws java.sql.SQLException
        Specified by:
        setLogWriter in interface javax.sql.CommonDataSource
        Specified by:
        setLogWriter in interface javax.sql.DataSource
        Overrides:
        setLogWriter in class DelegatingDataSource
        Throws:
        java.sql.SQLException
      • setLoginTimeout

        public void setLoginTimeout​(int seconds)
                             throws java.sql.SQLException
        Specified by:
        setLoginTimeout in interface javax.sql.CommonDataSource
        Specified by:
        setLoginTimeout in interface javax.sql.DataSource
        Overrides:
        setLoginTimeout in class DelegatingDataSource
        Throws:
        java.sql.SQLException
      • getParentLogger

        public java.util.logging.Logger getParentLogger()
                                                 throws java.sql.SQLFeatureNotSupportedException
        Specified by:
        getParentLogger in interface javax.sql.CommonDataSource
        Overrides:
        getParentLogger in class DelegatingDataSource
        Throws:
        java.sql.SQLFeatureNotSupportedException