Package org.killbill.commons.embeddeddb
Class EmbeddedDB
- java.lang.Object
-
- org.killbill.commons.embeddeddb.EmbeddedDB
-
- Direct Known Subclasses:
GenericStandaloneDB
public abstract class EmbeddedDB extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEmbeddedDB.DBEngineprotected static classEmbeddedDB.ResultSetJob
-
Field Summary
Fields Modifier and Type Field Description protected List<String>allTablesprotected StringdatabaseNameprotected DataSourcedataSourceprotected StringjdbcConnectionStringprotected static org.slf4j.Loggerloggerprotected Stringpasswordprotected Stringusername
-
Constructor Summary
Constructors Modifier Constructor Description protectedEmbeddedDB(String databaseName, String username, String password, String jdbcConnectionString)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcleanupAllTables()voidcleanupTable(String table)protected DataSourcecreateHikariDataSource()protected voidexecute(String query)protected voidexecute(String query, EmbeddedDB.ResultSetJob job)protected voidexecuteQuery(String query, EmbeddedDB.ResultSetJob job)voidexecuteScript(String script)protected intexecuteUpdate(String query)List<String>getAllTables()StringgetCmdLineConnectionString()protected ConnectiongetConnection()StringgetDatabaseName()DataSourcegetDataSource()abstract EmbeddedDB.DBEnginegetDBEngine()StringgetJdbcConnectionString()StringgetPassword()protected intgetPort()StringgetUsername()abstract voidinitialize()abstract voidrefreshTableNames()voidsetDataSource(DataSource dataSource)abstract voidstart()voidstop()booleanuseConnectionPooling()
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
databaseName
protected String databaseName
-
username
protected String username
-
password
protected String password
-
jdbcConnectionString
protected String jdbcConnectionString
-
dataSource
protected DataSource dataSource
-
-
Method Detail
-
useConnectionPooling
public boolean useConnectionPooling()
-
getDBEngine
public abstract EmbeddedDB.DBEngine getDBEngine()
-
initialize
public abstract void initialize() throws IOException, SQLException- Throws:
IOExceptionSQLException
-
start
public abstract void start() throws IOException, SQLException- Throws:
IOExceptionSQLException
-
refreshTableNames
public abstract void refreshTableNames() throws IOException- Throws:
IOException
-
getDataSource
public DataSource getDataSource() throws IOException
- Throws:
IOException
-
setDataSource
public void setDataSource(DataSource dataSource)
-
stop
public void stop() throws IOException- Throws:
IOException
-
getCmdLineConnectionString
public String getCmdLineConnectionString()
-
getUsername
public String getUsername()
-
getPassword
public String getPassword()
-
getDatabaseName
public String getDatabaseName()
-
getJdbcConnectionString
public String getJdbcConnectionString()
-
createHikariDataSource
protected DataSource createHikariDataSource() throws IOException
- Throws:
IOException
-
executeScript
public void executeScript(String script) throws IOException
- Throws:
IOException
-
cleanupAllTables
public void cleanupAllTables() throws IOException- Throws:
IOException
-
cleanupTable
public void cleanupTable(String table) throws IOException
- Throws:
IOException
-
execute
protected void execute(String query) throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
execute
protected void execute(String query, EmbeddedDB.ResultSetJob job) throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
executeUpdate
protected int executeUpdate(String query) throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
executeQuery
protected void executeQuery(String query, EmbeddedDB.ResultSetJob job) throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
getConnection
protected Connection getConnection() throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
getPort
protected int getPort()
-
-