Class DatabaseUtil


  • public abstract class DatabaseUtil
    extends Object
     This abstract class provides the ability to create/clear/remove a database
     and its tables.
     It also provides a 'javax.sql.DataSource' for the database.
     Finally, sql operations can be executed on the database through the retrieval
     of the 'JdbcOperations' object provided by the method: getOps().
     
    Author:
    Andrew Woods
    • Field Detail

      • log

        protected final org.slf4j.Logger log
      • NOT_ENCRYPTED

        public static String NOT_ENCRYPTED
    • Method Detail

      • getTableSpecs

        protected abstract List<TableSpec> getTableSpecs()
      • initializeDB

        public void initializeDB()
                          throws Exception
        This method sets-up empty tables for this database.
        Throws:
        Exception
      • ensureDatabaseExists

        public void ensureDatabaseExists()
      • clearDB

        public void clearDB()
      • disconnect

        public void disconnect()
      • getSimpleJdbcTemplate

        public org.springframework.jdbc.core.JdbcTemplate getSimpleJdbcTemplate()
      • getDataSource

        public DataSource getDataSource()
      • getOps

        public org.springframework.jdbc.core.JdbcOperations getOps()
      • execute

        protected void execute​(String sql)