@ThreadSafe public final class ConnectionFactory extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DB_STRUCTURE_RESOURCE
Resource location for SQL file used to create the database schema.
|
static String |
DB_STRUCTURE_UPDATE_RESOURCE
Resource location for SQL file used to create the database schema.
|
static String |
UPGRADE_HELP_URL
The URL that discusses upgrading non-H2 databases.
|
| Constructor and Description |
|---|
ConnectionFactory(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.
|
Connection |
getConnection()
Constructs a new database connection object per the database
configuration.
|
static File |
getH2DataFile(Settings configuration)
Returns a reference to the H2 database file.
|
boolean |
h2DataFileExists()
Determines if the H2 database file exists.
|
static boolean |
h2DataFileExists(Settings configuration)
Determines if the H2 database file exists.
|
void |
initialize()
Initializes the connection factory.
|
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.
|
public static final String DB_STRUCTURE_RESOURCE
public static final String DB_STRUCTURE_UPDATE_RESOURCE
public static final String UPGRADE_HELP_URL
public ConnectionFactory(Settings settings)
settings - the configured settingspublic void initialize()
throws DatabaseException
DatabaseException - thrown if we are unable to connect to the
databasepublic void cleanup()
public Connection getConnection() throws DatabaseException
DatabaseException - thrown if there is an exception loading the
database connectionpublic boolean h2DataFileExists()
throws IOException
IOException - thrown if the data directory does not exist and
cannot be createdpublic static boolean h2DataFileExists(Settings configuration) throws IOException
configuration - the configured settingsIOException - thrown if the data directory does not exist and
cannot be createdpublic static File getH2DataFile(Settings configuration) throws IOException
configuration - the configured settingsIOException - thrown if there is an errorpublic boolean isH2Connection()
public static boolean isH2Connection(Settings configuration)
configuration - the configured settingsCopyright © 2012–2020 OWASP. All rights reserved.