public abstract class DatabaseUtil extends Object
This abstract class provides the ability to create/clear/remove a database and its tables. It also provides a 'javax.sql.DataSource' for the database. Finally, sql operations can be executed on the database through the retrieval of the 'JdbcOperations' object provided by the method: getOps().
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
static String |
NOT_ENCRYPTED |
Constructor and Description |
---|
DatabaseUtil(Credential cred,
String baseDir) |
DatabaseUtil(Credential cred,
String baseDir,
String bootPassword) |
Modifier and Type | Method and Description |
---|---|
void |
clearDB() |
void |
disconnect() |
void |
ensureDatabaseExists() |
void |
ensureTablesExist() |
protected void |
execute(String sql) |
DataSource |
getDataSource() |
org.springframework.jdbc.core.JdbcOperations |
getOps() |
org.springframework.jdbc.core.simple.SimpleJdbcTemplate |
getSimpleJdbcTemplate() |
protected abstract List<TableSpec> |
getTableSpecs() |
void |
initializeDB()
This method sets-up empty tables for this database.
|
protected final org.slf4j.Logger log
public static String NOT_ENCRYPTED
public DatabaseUtil(Credential cred, String baseDir)
public DatabaseUtil(Credential cred, String baseDir, String bootPassword)
public void initializeDB() throws Exception
Exception
public void ensureDatabaseExists()
public void ensureTablesExist() throws SQLException
SQLException
public void clearDB()
public void disconnect()
public org.springframework.jdbc.core.simple.SimpleJdbcTemplate getSimpleJdbcTemplate()
public DataSource getDataSource()
public org.springframework.jdbc.core.JdbcOperations getOps()
protected void execute(String sql)
Copyright © 2009–2014 DuraSpace. All rights reserved.