Class DerbyMaster
- java.lang.Object
- 
- com.ibm.fhir.database.utils.derby.DerbyMaster
 
- 
- All Implemented Interfaces:
- java.lang.AutoCloseable
 
 public class DerbyMaster extends java.lang.Object implements java.lang.AutoCloseableSet up an instance of Derby for use with unit tests
- 
- 
Constructor SummaryConstructors Constructor Description DerbyMaster(java.lang.String database)Public constructor
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcreateSchema(IConnectionProvider pool, IVersionHistoryService vhs, PhysicalDataModel pdm)Ask the schema to apply itself to our target (adapter pattern)voidcreateSchema(IConnectionProvider pool, PhysicalDataModel pdm)Ask the schema to apply itself to our target (adapter pattern)voidcreateSchemaIfNeeded(java.lang.String schemaName)Derby setSchema fails if the schema doesn't exist, so we need to create that now in order for our connections to succeed when we build out the FHIR databasestatic voiddropDatabase(java.lang.String database)Drop the contents of the database on disk.voiddumpLockInfo()Diagnostic utility to display all the current locks in the Derby databasestatic voiddumpLockInfo(java.sql.Connection c)Dump locks using the given connectionjava.sql.ConnectiongetConnection()Get a connection to the configured Derby database, creating the database if necessary.IDatabaseTranslatorgetTranslator()Get the statement translator we use for DerbyvoidrunWithAdapter(IConnectionProvider pool, java.util.function.Consumer<IDatabaseAdapter> fn)Run theIDatabaseAdaptercommand fn using a DerbyAdapter for the given connection poolvoidrunWithAdapter(java.util.function.Consumer<IDatabaseAdapter> fn)Run the function with an adapter configured for this databasestatic voidshutdown(java.lang.String databaseName)
 
- 
- 
- 
Method Detail- 
createSchemaIfNeededpublic void createSchemaIfNeeded(java.lang.String schemaName) Derby setSchema fails if the schema doesn't exist, so we need to create that now in order for our connections to succeed when we build out the FHIR database- Parameters:
- schemaName-
 
 - 
dropDatabasepublic static void dropDatabase(java.lang.String database) Drop the contents of the database on disk. Must contain 'derby/' in the path as a simple check against accidentally wiping the wrong files- Parameters:
- database-
 
 - 
getConnectionpublic java.sql.Connection getConnection() throws java.sql.SQLExceptionGet a connection to the configured Derby database, creating the database if necessary.- Returns:
- Throws:
- java.sql.SQLException
 
 - 
getTranslatorpublic IDatabaseTranslator getTranslator() Get the statement translator we use for Derby- Returns:
 
 - 
createSchemapublic void createSchema(IConnectionProvider pool, PhysicalDataModel pdm) Ask the schema to apply itself to our target (adapter pattern)- Parameters:
- pool- the connection pool
- pdm- the data model to create
 
 - 
createSchemapublic void createSchema(IConnectionProvider pool, IVersionHistoryService vhs, PhysicalDataModel pdm) Ask the schema to apply itself to our target (adapter pattern)- Parameters:
- pool- the connection pool
- vhs- current version history service
- pdm- the data model we want to create
 
 - 
runWithAdapterpublic void runWithAdapter(IConnectionProvider pool, java.util.function.Consumer<IDatabaseAdapter> fn) Run theIDatabaseAdaptercommand fn using a DerbyAdapter for the given connection pool- Parameters:
- pool- provides database connections
- fn- the command to execute
 
 - 
runWithAdapterpublic void runWithAdapter(java.util.function.Consumer<IDatabaseAdapter> fn) Run the function with an adapter configured for this database- Parameters:
- fn-
 
 - 
dumpLockInfopublic void dumpLockInfo() Diagnostic utility to display all the current locks in the Derby database
 - 
dumpLockInfopublic static void dumpLockInfo(java.sql.Connection c) Dump locks using the given connection- Parameters:
- c-
 
 - 
closepublic void close() throws java.lang.Exception- Specified by:
- closein interface- java.lang.AutoCloseable
- Throws:
- java.lang.Exception
 
 - 
shutdownpublic static void shutdown(java.lang.String databaseName) 
 
- 
 
-