Class DatabaseChecker
-
- All Implemented Interfaces:
public class DatabaseCheckercheck the timezone between mysql server, application, and jdbc session. see time-zone-variables
- Since:
2021-04-14
trydofor
-
-
Constructor Summary
Constructors Constructor Description DatabaseChecker()
-
Method Summary
Modifier and Type Method Description static booleanisH2(DataSource ds)Whether in H2database static StringextractJdbcUrl(DataSource ds)Extract the jdbc-url from the datasource static voidtimezone(DataSource ds)Check timezone with off=5, fail=true static voidtimezone(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 longversion(DataSource ds)output the database version in the log, return flywave revision if found static booleanexistTable(Connection conn, String table)Whether the table exist, need close the `conn` manually. -
-
Method Detail
-
isH2
static boolean isH2(DataSource ds)
Whether in H2database
-
extractJdbcUrl
@NotNull() static String extractJdbcUrl(DataSource ds)
Extract the jdbc-url from the datasource
-
timezone
static void timezone(DataSource ds)
Check timezone with off=5, fail=true
-
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- datasourceoff- max abs time tolerance in secondfail- throw IllegalStateException or log.
-
version
static long version(DataSource ds)
output the database version in the log, return flywave revision if found
-
existTable
static boolean existTable(Connection conn, String table)
Whether the table exist, need close the `conn` manually. `SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME=? AND TABLE_SCHEMA=SCHEMA()` current-schema-function
-
-
-
-