Package adams.db

Class DatabaseManager<T extends AbstractDatabaseConnection>

    • Constructor Detail

      • DatabaseManager

        public DatabaseManager​(String dbName)
        Initializes the manager.
        Parameters:
        dbName - the name of the database this manager is for
    • Method Detail

      • getDatabaseName

        public String getDatabaseName()
        Returns the name of the database this manager is handling.
        Returns:
        the database name
      • createURL

        public String createURL​(T dbcon)
        Generates a URL that includes the user name.
        Parameters:
        dbcon - the database connection object to create the URL for
        Returns:
        the complete URL
      • createURL

        public String createURL​(String url,
                                String user,
                                BasePassword password)
        Generates a URL that includes the user name.
        Parameters:
        url - the JDBC URL
        user - the database user
        password - the database password
        Returns:
        the complete URL
      • has

        public boolean has​(String url,
                           String user,
                           BasePassword password)
        Checks whether a database object for the specified URL is available.
        Parameters:
        url - the URL to check
        user - the database user
        password - the database password
        Returns:
        true if a database object is available
      • get

        public T get​(String url,
                     String user,
                     BasePassword password)
        Gets the database object for the specified URL.
        Parameters:
        url - the URL to get the database for
        user - the database user
        password - the database password
        Returns:
        the database object if available, otherwise null
      • add

        public T add​(T dbcon)
        Adds the database object (uses the current URL as key).
        Parameters:
        dbcon - the database object to add
        Returns:
        the previous database, null if no previous one stored
      • setDefault

        public void setDefault​(T value)
        Sets the default database connection.
        Parameters:
        value - the default connection object
      • getDefault

        public T getDefault()
        Returns the default database connection.
        Returns:
        the default
      • iterator

        public Iterator<T> iterator()
        Returns an iterator over all databases.
        Returns:
        the iterator
      • toString

        public String toString()
        Returns a short string representation of the manager.
        Overrides:
        toString in class Object
        Returns:
        the string representation
      • getConnectionObjects

        public static List<AbstractDatabaseConnection> getConnectionObjects()
        Returns the connection objects.
        Returns:
        the connection objects
      • getActiveConnectionObjects

        public static List<AbstractDatabaseConnection> getActiveConnectionObjects()
        Returns active (ie currently connected) connection objects.
        Returns:
        the connection objects
      • disconnectConnections

        public void disconnectConnections()
        Performs a disconnect on all connects and removes them.
        See Also:
        m_Connections
      • disconnectAllConnections

        public static void disconnectAllConnections()
        Performs a disconnect on all connects and removes them.
        See Also:
        m_AllConnections