Skip navigation links
uk.ac.ed.epcc.webapp.jdbc

Class DefaultDataBaseService

    • Field Detail

      • TRANSACTIONS_FEATURE

        public static final Feature TRANSACTIONS_FEATURE
      • TRANSACTIONS_SERIALIZE_FEATURE

        public static final Feature TRANSACTIONS_SERIALIZE_FEATURE
      • TRANSACTIONS_ROLLBACK_TRANSIENT_ERRORS

        public static final Feature TRANSACTIONS_ROLLBACK_TRANSIENT_ERRORS
      • POSTGRESQL_TYPE

        protected static final java.lang.String POSTGRESQL_TYPE
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultDataBaseService

        public DefaultDataBaseService(AppContext ctx)
    • Method Detail

      • getSQLContext

        public SQLContext getSQLContext(java.lang.String tag,
                                        java.util.Properties props)
                                 throws java.sql.SQLException
        returns a database connection for the application based on a set of Config Propertis
        Specified by:
        getSQLContext in interface DatabaseService
        Returns:
        A SQLContext
        Throws:
        java.sql.SQLException
      • setSQLContext

        protected void setSQLContext(SQLContext c)
                              throws java.sql.SQLException
        Set the database Connection. Should be called from sub-class constructor
        Parameters:
        c - the Connection to use
        Throws:
        java.sql.SQLException
      • makeSQLContext

        protected SQLContext makeSQLContext(java.lang.String tag,
                                            java.util.Properties props)
                                     throws java.sql.SQLException
        default method for creating a SQLContext from InitParameters This method is only invoked the first time an AppContext needs a Connection to reduce overhead in static pages.
        Returns:
        A database Connection
        Throws:
        java.sql.SQLException
      • cleanup

        public void cleanup()
        Description copied from interface: AppContextCleanup
        AppContext is being closed. Only use this for cleanup that can't be handled by normal garbage collection or for state which is never returned by reference.
        Specified by:
        cleanup in interface AppContextCleanup
      • getTargetIsolationLevel

        public int getTargetIsolationLevel()
        Returns:
      • commitTransaction

        public void commitTransaction()
        Description copied from interface: DatabaseService
        flush changes since start of last commit. Unlike the commit method of a Connection this is a NOP if not in a transaction. Call before an operation that modifies external state as these won't roll-back. However probably better to defer the external state change using the CleanupService unless the transaction phases all make sense in their own right.
        Specified by:
        commitTransaction in interface DatabaseService
      • handleError

        public void handleError(java.lang.String message,
                                java.sql.SQLException e)
                         throws DataFault
        Description copied from interface: DatabaseService
        Handle an unexpected database exception. Most of the time this will just re-throw the exception wrapped in a DataFault however this also allow special handing of certain classes of error such as SQLTransientExceptions
        Specified by:
        handleError in interface DatabaseService
        Throws:
        DataFault
      • logError

        public void logError(java.lang.String message,
                             java.sql.SQLException e)
        Description copied from interface: DatabaseService
        handle an SQLException directly. Normally this will just log the error however this also allow special handing of certain classes of error such as SQLTransientExceptions
        Specified by:
        logError in interface DatabaseService
      • parseLevel

        public static int parseLevel(java.lang.String name)
      • addClosable

        public void addClosable(java.lang.AutoCloseable c)
        Specified by:
        addClosable in interface CloseRegistry
      • getConnectionAttributes

        public java.util.Map<java.lang.String,java.lang.Object> getConnectionAttributes()
                                                                                 throws java.lang.Exception
        Description copied from interface: DatabaseService
        get a map of information about the connection
        Specified by:
        getConnectionAttributes in interface DatabaseService
        Returns:
        Throws:
        java.lang.Exception