Class AbstractDatabase

    • Constructor Detail

      • AbstractDatabase

        protected AbstractDatabase​(String url)
        Instantiates a new AbstractDatabase.
        Parameters:
        url - the jdbc url
    • Method Detail

      • url

        public final String url()
        Description copied from interface: ConnectionFactory
        Returns the jdbc database url for this connection factory.
        Specified by:
        url in interface ConnectionFactory
        Returns:
        the jdbc database url for this connection factory.
      • isConnectionValid

        public final boolean isConnectionValid​(Connection connection)
        Description copied from interface: ConnectionFactory
        Validates the given connection.
        Specified by:
        isConnectionValid in interface ConnectionFactory
        Parameters:
        connection - the connection to validate
        Returns:
        true if the connection is valid
      • countQuery

        public final void countQuery​(String query)
        Description copied from interface: Database
        Counts this query, based on the first character.
        Specified by:
        countQuery in interface Database
        Parameters:
        query - the query to count
        See Also:
        Database.statistics()
      • createConnectionPool

        public final void createConnectionPool​(ConnectionPoolFactory connectionPoolFactory,
                                               User poolUser)
                                        throws DatabaseException
        Description copied from interface: Database
        Creates a connection pool for the given user in this database.
        Specified by:
        createConnectionPool in interface Database
        Parameters:
        connectionPoolFactory - the ConnectionPoolFactory implementation to use
        poolUser - the user for which to create a connection pool
        Throws:
        DatabaseException - in case of a database exception
      • connectionPool

        public final ConnectionPoolWrapper connectionPool​(String username)
        Specified by:
        connectionPool in interface Database
        Parameters:
        username - the username
        Returns:
        the connection pool for the given user, null if none exists
      • closeConnectionPool

        public final void closeConnectionPool​(String username)
        Description copied from interface: Database
        Closes and removes the pool associated with the given user
        Specified by:
        closeConnectionPool in interface Database
        Parameters:
        username - the username of the pool that should be removed
      • closeConnectionPools

        public final void closeConnectionPools()
        Description copied from interface: Database
        Closes and removes all available connection pools
        Specified by:
        closeConnectionPools in interface Database
      • subqueryRequiresAlias

        public boolean subqueryRequiresAlias()
        Description copied from interface: Database
        Returns true if this database requires that subqueries by aliased.
        Specified by:
        subqueryRequiresAlias in interface Database
        Returns:
        true if subqueries require an alias
      • maximumNumberOfParameters

        public int maximumNumberOfParameters()
        Description copied from interface: Database
        Returns the maximum number of prepared statement parameters, supported by this database. The default implementation simply returns Integer.MAX_VALUE, as in, no limit.
        Specified by:
        maximumNumberOfParameters in interface Database
        Returns:
        the maximum number of prepared statement parameters, supported by this database.
      • checkConnectionQuery

        public String checkConnectionQuery()
        Description copied from interface: Database
        Returns a query to use when checking if the connection is valid, this is used in cases where the dbms does not support the isValid() call. Returning null is safe if isValid() is supported.
        Specified by:
        checkConnectionQuery in interface Database
        Returns:
        a check connection query
        See Also:
        Database.supportsIsValid()
      • validityCheckTimeout

        public int validityCheckTimeout()
        Specified by:
        validityCheckTimeout in interface Database
        Returns:
        the timeout in seconds to use when checking connection validity
      • shutdownEmbedded

        public void shutdownEmbedded()
        Description copied from interface: Database
        This should shut down the database in case it is an embedded one and if that is applicable, such as for Derby.
        Specified by:
        shutdownEmbedded in interface Database
      • sequenceQuery

        public String sequenceQuery​(String sequenceName)
        Description copied from interface: Database
        Returns a query string for selecting the next value from the given sequence.
        Specified by:
        sequenceQuery in interface Database
        Parameters:
        sequenceName - the name of the sequence
        Returns:
        a query for selecting the next value from the given sequence
      • errorMessage

        public String errorMessage​(SQLException exception)
        Description copied from interface: Database
        Returns a user-friendly error message for the given exception, otherwise simply return the message from exception
        Specified by:
        errorMessage in interface Database
        Parameters:
        exception - the underlying SQLException
        Returns:
        the message assigned to the given exception
      • isAuthenticationException

        public boolean isAuthenticationException​(SQLException exception)
        This default implementation returns false
        Specified by:
        isAuthenticationException in interface Database
        Parameters:
        exception - the exception
        Returns:
        false
      • isReferentialIntegrityException

        public boolean isReferentialIntegrityException​(SQLException exception)
        This default implementation returns false
        Specified by:
        isReferentialIntegrityException in interface Database
        Parameters:
        exception - the exception
        Returns:
        false
      • isUniqueConstraintException

        public boolean isUniqueConstraintException​(SQLException exception)
        Description copied from interface: Database
        Returns true if this exception is a unique key exception
        Specified by:
        isUniqueConstraintException in interface Database
        Parameters:
        exception - the exception
        Returns:
        true if this exception is a unique key exception
      • isTimeoutException

        public boolean isTimeoutException​(SQLException exception)
        Description copied from interface: Database
        Returns true if this exception is a timeout exception
        Specified by:
        isTimeoutException in interface Database
        Parameters:
        exception - the exception
        Returns:
        true if this exception is a timeout exception
      • loginTimeout

        protected int loginTimeout()
        Returns:
        the connection timeout in seconds
        See Also:
        Database.LOGIN_TIMEOUT
      • createLimitOffsetClause

        protected static final String createLimitOffsetClause​(Integer limit,
                                                              Integer offset)
      • createOffsetFetchNextClause

        protected static final String createOffsetFetchNextClause​(Integer limit,
                                                                  Integer offset)
      • removeUrlPrefixOptionsAndParameters

        protected static String removeUrlPrefixOptionsAndParameters​(String url,
                                                                    String... prefixes)