@ThreadSafe
public final class DatabaseManager
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DB_STRUCTURE_RESOURCE
Resource location for SQL file used to create the database schema.
|
static java.lang.String |
DB_STRUCTURE_UPDATE_RESOURCE
Resource location for SQL file used to create the database schema.
|
static java.lang.String |
UPGRADE_HELP_URL
The URL that discusses upgrading non-H2 databases.
|
| Constructor and Description |
|---|
DatabaseManager(Settings settings)
Private constructor for this factory class; no instance is ever needed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup()
Cleans up resources and unloads any registered database drivers.
|
void |
close()
Closes the database connection pool.
|
java.sql.Connection |
getConnection()
Constructs a new database connection object per the database
configuration.
|
java.lang.String |
getDatabaseProductName()
Returns the database product name.
|
static java.io.File |
getH2DataFile(Settings configuration)
Returns a reference to the H2 database file.
|
java.util.ResourceBundle |
getSqlStatements()
Returns a resource bundle containing the SQL Statements needed for the
database engine being used.
|
boolean |
h2DataFileExists()
Determines if the H2 database file exists.
|
static boolean |
h2DataFileExists(Settings configuration)
Determines if the H2 database file exists.
|
boolean |
isH2Connection()
Determines if the connection string is for an H2 database.
|
static boolean |
isH2Connection(Settings configuration)
Determines if the connection string is for an H2 database.
|
static boolean |
isH2Connection(java.lang.String connectionString)
Determines if the connection string is for an H2 database.
|
boolean |
isOpen()
Returns if the connection pool is open.
|
boolean |
isOracle()
Determines if the connection string is for an Oracle database.
|
void |
open()
Opens the database connection pool.
|
public static final java.lang.String DB_STRUCTURE_RESOURCE
public static final java.lang.String DB_STRUCTURE_UPDATE_RESOURCE
public static final java.lang.String UPGRADE_HELP_URL
public DatabaseManager(Settings settings) throws DatabaseException
settings - the configured settingsDatabaseException - thrown if we are unable to connect to the
databasepublic void cleanup()
public boolean h2DataFileExists()
throws java.io.IOException
java.io.IOException - thrown if the data directory does not exist and
cannot be createdpublic static boolean h2DataFileExists(Settings configuration) throws java.io.IOException
configuration - the configured settingsjava.io.IOException - thrown if the data directory does not exist and
cannot be createdpublic static java.io.File getH2DataFile(Settings configuration) throws java.io.IOException
configuration - the configured settingsjava.io.IOException - thrown if there is an errorpublic java.lang.String getDatabaseProductName()
public boolean isH2Connection()
public boolean isOracle()
public static boolean isH2Connection(Settings configuration)
configuration - the configured settingspublic static boolean isH2Connection(java.lang.String connectionString)
connectionString - the connection stringpublic java.util.ResourceBundle getSqlStatements()
public void open()
public void close()
public boolean isOpen()
public java.sql.Connection getConnection()
throws DatabaseException
DatabaseException - thrown if there is an exception obtaining the
database connectionCopyright© 2012-21 Jeremy Long. All Rights Reserved.