@groovy.util.logging.Slf4j @groovy.transform.CompileStatic class H2DatabaseCleanupHelper extends java.lang.Object
Helper utility for H2 database cleanup operations. Provides H2-specific logic such as resolving the schema name from a javax.sql.DataSource by inspecting JDBC connection metadata and parsing H2 JDBC URLs.
| Constructor and description |
|---|
H2DatabaseCleanupHelper() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static java.lang.String |
extractSchemaFromUrl(java.lang.String url)Extracts the database name from an H2 JDBC URL and converts it to the uppercase schema name that H2 uses. |
|
static java.lang.String |
resolveSchemaName(javax.sql.DataSource dataSource)Resolves the schema name for the given H2 datasource by inspecting the JDBC connection metadata. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Extracts the database name from an H2 JDBC URL and converts it to the uppercase schema name that H2 uses.
Examples:
jdbc:h2:mem:testDb → TESTDBjdbc:h2:mem:grailsDB → GRAILSDBjdbc:h2:mem:testDb;LOCK_TIMEOUT=10000 → TESTDBurl - the JDBC URLnull if the URL format is not recognized Resolves the schema name for the given H2 datasource by inspecting the JDBC connection metadata.
For H2, the schema name corresponds to the uppercase database name from the JDBC URL
(e.g., jdbc:h2:mem:testDb results in schema TESTDB).
dataSource - the datasource to resolve the schema fornull if it cannot be determined