Class DatabaseChecker

  • All Implemented Interfaces:

    
    public class DatabaseChecker
    
                        

    check the timezone between mysql server, application, and jdbc session. see time-zone-variables

    Since:

    2021-04-14

    Author:

    trydofor

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static boolean isH2(DataSource ds) Whether in H2database
      static String extractJdbcUrl(DataSource ds) Extract the jdbc-url from the datasource
      static void timezone(DataSource ds) Check timezone with off=5, fail=true
      static void timezone(DataSource ds, int off, boolean fail) Check the database and jvm time difference, in the absolute `off` second, throw or log as ERROR if `fail`.
      static long version(DataSource ds) output the database version in the log, return flywave revision if found
      static boolean existTable(Connection conn, String table) Whether the table exist, need close the `conn` manually.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DatabaseChecker

        DatabaseChecker()
    • Method Detail

      • timezone

         static void timezone(DataSource ds, int off, boolean fail)

        Check the database and jvm time difference, in the absolute `off` second, throw or log as ERROR if `fail`.

        Parameters:
        ds - datasource
        off - max abs time tolerance in second
        fail - throw IllegalStateException or log.
      • version

         static long version(DataSource ds)

        output the database version in the log, return flywave revision if found