本文整理匯總了Java中liquibase.database.DatabaseFactory.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseFactory.getInstance方法的具體用法?Java DatabaseFactory.getInstance怎麽用?Java DatabaseFactory.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類liquibase.database.DatabaseFactory
的用法示例。
在下文中一共展示了DatabaseFactory.getInstance方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: invoke
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
@Override
public List<Map<String, ?>> invoke() {
StandardChangeLogHistoryService service = new StandardChangeLogHistoryService();
try {
DatabaseFactory factory = DatabaseFactory.getInstance();
DataSource dataSource = this.liquibase.getDataSource();
JdbcConnection connection = new JdbcConnection(dataSource.getConnection());
try {
Database database = factory.findCorrectDatabaseImplementation(connection);
return service.queryDatabaseChangeLogTable(database);
}
finally {
connection.close();
}
}
catch (Exception ex) {
throw new IllegalStateException("Unable to get Liquibase changelog", ex);
}
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:20,代碼來源:LiquibaseEndpoint.java
示例2: createDatabase
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
protected Database createDatabase(Connection c, ResourceAccessor resourceAccessor) throws DatabaseException {
DatabaseConnection liquibaseConnection = new JdbcConnection(c);
DatabaseFactory databaseFactory = DatabaseFactory.getInstance();
// expand factory with our extensions....
databaseFactory.register(new DerbyDatabase());
Database database = databaseFactory.findCorrectDatabaseImplementation(liquibaseConnection);
// set default schema
String defaultSchema = cli.optionString(LiquibaseModule.DEFAULT_SCHEMA_OPTION);
if (defaultSchema != null) {
database.setDefaultSchemaName(defaultSchema);
}
return database;
}
示例3: invoke
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
@Override
public List<Map<String, ?>> invoke() {
StandardChangeLogHistoryService service = new StandardChangeLogHistoryService();
try {
DatabaseFactory factory = DatabaseFactory.getInstance();
DataSource dataSource = this.liquibase.getDataSource();
JdbcConnection connection = new JdbcConnection(dataSource.getConnection());
Database database = factory.findCorrectDatabaseImplementation(connection);
return service.queryDatabaseChangeLogTable(database);
}
catch (Exception ex) {
throw new IllegalStateException("Unable to get Liquibase changelog", ex);
}
}
示例4: init
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
@Override
public void init() {
if (configuration.getBoolean(LIQUIBASE_ENABLED, true)) {
logger.info("Setting up Liquibase");
DatabaseFactory databaseFactory = DatabaseFactory.getInstance();
logger.debug("Clearing Liquibase database factory registry");
databaseFactory.clearRegistry();
logger.debug("Clearing Liquibase database snapshot generator factory registry");
List<DatabaseSnapshotGenerator> registry = DatabaseSnapshotGeneratorFactory.getInstance().getRegistry();
registry.clear();
SqlGeneratorFactory.getInstance().register(new PortofinoSelectFromDatabaseChangeLogLockGenerator());
} else {
logger.info("Liquibase is disabled");
}
logger.info("Initializing persistence");
DatabasePlatformsRegistry databasePlatformsRegistry = new DatabasePlatformsRegistry(configuration);
persistence = new Persistence(applicationDirectory, configuration, databasePlatformsRegistry);
Injections.inject(persistence, servletContext, null);
servletContext.setAttribute(DATABASE_PLATFORMS_REGISTRY, databasePlatformsRegistry);
servletContext.setAttribute(PERSISTENCE, persistence);
appendToAdminMenu();
// hongliangpan add
DbUtils.setPersistence(persistence);
status = ModuleStatus.ACTIVE;
}
示例5: syncDatabase
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
public Database syncDatabase(Model sourceModel) throws Exception {
String databaseName = connectionProvider.getDatabase().getDatabaseName();
Database targetDatabase = new Database();
targetDatabase.setDatabaseName(databaseName);
Connection conn = null;
try {
logger.debug("Acquiring connection");
conn = connectionProvider.acquireConnection();
logger.debug("Creating Liquibase connection");
DatabaseConnection liquibaseConnection = new JdbcConnection(conn);
logger.debug("Retrieving source database");
Database sourceDatabase =
DatabaseLogic.findDatabaseByName(sourceModel, databaseName);
if (sourceDatabase == null) {
logger.debug("Source database not found. Creating an empty one.");
sourceDatabase = new Database();
} else {
logger.debug("Source database was already configured. Copying true string and false string.");
targetDatabase.setTrueString(sourceDatabase.getTrueString());
targetDatabase.setFalseString(sourceDatabase.getFalseString());
}
logger.debug("Reading schema names from metadata");
List<Schema> schemas = connectionProvider.getDatabase().getSchemas();
SnapshotGeneratorFactory dsgf = SnapshotGeneratorFactory.getInstance();
logger.debug("Finding Liquibase database");
DatabaseFactory databaseFactory = DatabaseFactory.getInstance();
liquibase.database.Database liquibaseDatabase =
databaseFactory.findCorrectDatabaseImplementation(liquibaseConnection);
for (Schema schema : schemas) {
String schemaName = schema.getSchemaName();
logger.info("Processing schema: {}", schemaName);
Schema sourceSchema =
DatabaseLogic.findSchemaByNameIgnoreCase(
sourceDatabase, schemaName);
if (sourceSchema == null) {
logger.debug("Source schema not found. Creating an empty one.");
sourceSchema = new Schema();
sourceSchema.setSchemaName(schemaName);
}
logger.debug("Creating Liquibase database snapshot");
String catalog = null;
if(sourceSchema.getCatalog() != null) {
catalog = sourceSchema.getCatalog();
}
SnapshotControl snapshotControl = new SnapshotControl(liquibaseDatabase);
DatabaseSnapshot snapshot =
dsgf.createSnapshot(new CatalogAndSchema(catalog, schemaName), liquibaseDatabase, snapshotControl);
logger.debug("Synchronizing schema");
Schema targetSchema = new Schema();
targetSchema.setDatabase(targetDatabase);
targetSchema.setCatalog(catalog);
targetDatabase.getSchemas().add(targetSchema);
syncSchema(snapshot, sourceSchema, targetSchema);
}
} finally {
connectionProvider.releaseConnection(conn);
}
targetDatabase.setConnectionProvider(connectionProvider);
connectionProvider.setDatabase(targetDatabase);
return targetDatabase;
}
示例6: getLiquibaseDatabaseFactory
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
public DatabaseFactory getLiquibaseDatabaseFactory() {
return DatabaseFactory.getInstance();
}
示例7: syncDatabase
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
public Database syncDatabase() throws Exception {
columnMap.put("t_customer.c_name", insertHead + "'t_customer.c_name','客戶名稱','string" + insertTail);
initJdbc();
String databaseName = connectionProvider.getDatabase().getDatabaseName();
Database targetDatabase = new Database();
targetDatabase.setDatabaseName(databaseName);
Connection conn = null;
try {
logger.debug("Acquiring connection");
conn = connectionProvider.acquireConnection();
logger.debug("Reading database metadata");
// DatabaseMetaData metadata = conn.getMetaData();
logger.debug("Creating Liquibase connection");
DatabaseConnection liquibaseConnection = new JdbcConnection(conn);
logger.debug("Reading schema names from metadata");
List<Schema> schemas = connectionProvider.getDatabase().getSchemas();
DatabaseSnapshotGeneratorFactory dsgf = DatabaseSnapshotGeneratorFactory.getInstance();
logger.debug("Finding Liquibase database");
DatabaseFactory databaseFactory = DatabaseFactory.getInstance();
liquibase.database.Database liquibaseDatabase = databaseFactory
.findCorrectDatabaseImplementation(liquibaseConnection);
Schema t_schema = new Schema();
t_schema.setDatabase(connectionProvider.getDatabase());
t_schema.setSchemaName(S_SCHEMA);
schemas.add(t_schema);
for (Schema schema : schemas) {
if (!S_SCHEMA.equals(schema.getSchemaName())) {
continue;
}
logger.debug("Creating Liquibase database snapshot");
DatabaseSnapshot snapshot = dsgf.createSnapshot(liquibaseDatabase, schema.getSchemaName(), null);
logger.debug("Synchronizing schema");
syncSchema(snapshot, schema);
}
} finally {
connectionProvider.releaseConnection(conn);
}
targetDatabase.setConnectionProvider(connectionProvider);
connectionProvider.setDatabase(targetDatabase);
return targetDatabase;
}
示例8: syncDatabase
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
public Database syncDatabase() throws Exception {
initJdbc();
String databaseName = connectionProvider.getDatabase().getDatabaseName();
Database targetDatabase = new Database();
targetDatabase.setDatabaseName(databaseName);
Connection conn = null;
try {
logger.debug("Acquiring connection");
conn = connectionProvider.acquireConnection();
logger.debug("Reading database metadata");
// DatabaseMetaData metadata = conn.getMetaData();
logger.debug("Creating Liquibase connection");
DatabaseConnection liquibaseConnection = new JdbcConnection(conn);
logger.debug("Reading schema names from metadata");
List<Schema> schemas = connectionProvider.getDatabase().getSchemas();
DatabaseSnapshotGeneratorFactory dsgf = DatabaseSnapshotGeneratorFactory.getInstance();
logger.debug("Finding Liquibase database");
DatabaseFactory databaseFactory = DatabaseFactory.getInstance();
liquibase.database.Database liquibaseDatabase = databaseFactory
.findCorrectDatabaseImplementation(liquibaseConnection);
Schema t_schema = new Schema();
t_schema.setDatabase(connectionProvider.getDatabase());
t_schema.setSchemaName(S_SCHEMA);
schemas.add(t_schema);
for (Schema schema : schemas) {
if (!S_SCHEMA.equals(schema.getSchemaName())) {
continue;
}
logger.debug("Creating Liquibase database snapshot");
DatabaseSnapshot snapshot = dsgf.createSnapshot(liquibaseDatabase, schema.getSchemaName(), null);
logger.debug("Synchronizing schema");
syncSchema(snapshot, schema);
}
} finally {
connectionProvider.releaseConnection(conn);
}
targetDatabase.setConnectionProvider(connectionProvider);
connectionProvider.setDatabase(targetDatabase);
return targetDatabase;
}
示例9: syncDatabase
import liquibase.database.DatabaseFactory; //導入方法依賴的package包/類
public Database syncDatabase(final Model sourceModel) throws Exception {
String databaseName = connectionProvider.getDatabase().getDatabaseName();
Database targetDatabase = new Database();
targetDatabase.setDatabaseName(databaseName);
Connection conn = null;
try {
logger.debug("Acquiring connection");
conn = connectionProvider.acquireConnection();
logger.debug("Reading database metadata");
DatabaseMetaData metadata = conn.getMetaData();
logger.debug("Creating Liquibase connection");
DatabaseConnection liquibaseConnection = new JdbcConnection(conn);
logger.debug("Retrieving source database");
Database sourceDatabase = DatabaseLogic.findDatabaseByName(sourceModel, databaseName);
if (sourceDatabase == null) {
logger.debug("Source database not found. Creating an empty one.");
sourceDatabase = new Database();
}
logger.debug("Reading schema names from metadata");
List<Schema> schemas = connectionProvider.getDatabase().getSchemas();
DatabaseSnapshotGeneratorFactory dsgf = DatabaseSnapshotGeneratorFactory.getInstance();
logger.debug("Finding Liquibase database");
DatabaseFactory databaseFactory = DatabaseFactory.getInstance();
liquibase.database.Database liquibaseDatabase = databaseFactory
.findCorrectDatabaseImplementation(liquibaseConnection);
for (Schema schema : schemas) {
logger.info("Processing schema: {}", schema.getSchemaName());
Schema sourceSchema = DatabaseLogic.findSchemaByNameIgnoreCase(sourceDatabase, schema.getSchemaName());
if (sourceSchema == null) {
logger.debug("Source schema not found. Creating an empty one.");
sourceSchema = new Schema();
sourceSchema.setSchemaName(schema.getSchemaName());
}
logger.debug("Creating Liquibase database snapshot");
DatabaseSnapshot snapshot = dsgf.createSnapshot(liquibaseDatabase, schema.getSchemaName(), null);
logger.debug("Synchronizing schema");
Schema targetSchema = new Schema();
targetSchema.setDatabase(targetDatabase);
targetDatabase.getSchemas().add(targetSchema);
syncSchema(snapshot, sourceSchema, targetSchema);
}
} finally {
connectionProvider.releaseConnection(conn);
}
targetDatabase.setConnectionProvider(connectionProvider);
connectionProvider.setDatabase(targetDatabase);
return targetDatabase;
}