本文整理汇总了Java中liquibase.resource.FileSystemResourceAccessor类的典型用法代码示例。如果您正苦于以下问题:Java FileSystemResourceAccessor类的具体用法?Java FileSystemResourceAccessor怎么用?Java FileSystemResourceAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemResourceAccessor类属于liquibase.resource包,在下文中一共展示了FileSystemResourceAccessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initDatabaseSchema
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
private void initDatabaseSchema() throws SQLException, LiquibaseException {
if (config.hasKey("database.changelog")) {
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
Database database = DatabaseFactory.getInstance().openDatabase(
config.getString("database.url"),
config.getString("database.user"),
config.getString("database.password"),
null, resourceAccessor);
Liquibase liquibase = new Liquibase(
config.getString("database.changelog"), resourceAccessor, database);
liquibase.clearCheckSums();
liquibase.update(new Contexts());
}
}
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:21,代码来源:DataManager.java
示例2: createTestData
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@Before
public void createTestData() throws Exception {
Handle handle = dbiProvider.get().open();
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection()));
Liquibase liquibase = new Liquibase("singularity_test.sql", new FileSystemResourceAccessor(), database);
liquibase.update((String) null);
try {
database.close();
} catch (Throwable t) {
}
handle.close();
}
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:17,代码来源:SingularityHistoryTest.java
示例3: migrate
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
public void migrate(String dbName) {
try {
Configuration configuration = yamlConfiguration.subset(dbName+ ".Hibernate");
Properties properties = new Properties();
properties.put("user", configuration.getProperty("hibernate.connection.username"));
properties.put("password", configuration.getProperty("hibernate.connection.password"));
String url = (String) configuration.getProperty("hibernate.connection.url");
Class.forName("com.mysql.jdbc.Driver").newInstance();
java.sql.Connection connection = DriverManager.getConnection(url, properties);
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource(dbName+"/migrations.xml").getFile());
Liquibase liquibase = new Liquibase(file.getCanonicalPath(), new FileSystemResourceAccessor(), database);
liquibase.update(new Contexts());
} catch (Exception e) {
System.err.println("Unable to perform database migration.");
e.printStackTrace();
}
}
开发者ID:flipkart-incubator,项目名称:flux,代码行数:20,代码来源:MigrationsRunner.java
示例4: createTables
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
private void createTables(String changelog) {
Connection holdingConnection;
try {
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
holdingConnection = getConnectionImpl(USER_NAME, getPostgresPassword());
JdbcConnection conn = new JdbcConnection(holdingConnection);
PostgresDatabase database = new PostgresDatabase();
database.setDefaultSchemaName("public");
database.setConnection(conn);
liquibase = new Liquibase(changelog, resourceAccessor, database);
liquibase.dropAll();
liquibase.update("test");
conn.close();
} catch (SQLException | LiquibaseException ex) {
LOG.error("Error during createTable step", ex);
throw new RuntimeException("Error during createTable step", ex);
}
}
开发者ID:mbarre,项目名称:schemacrawler-additional-lints,代码行数:26,代码来源:PostgreSqlDatabase.java
示例5: createLiquibase
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
protected Liquibase createLiquibase() throws Exception {
ResourceAccessor antFO = new AntResourceAccessor(getProject(), classpath);
ResourceAccessor fsFO = new FileSystemResourceAccessor();
Database database = createDatabaseObject(getDriver(), getUrl(), getUsername(), getPassword(), getDefaultSchemaName(), getDatabaseClass());
String changeLogFile = null;
if (getChangeLogFile() != null) {
changeLogFile = getChangeLogFile().trim();
}
Liquibase liquibase = new Liquibase(changeLogFile, new CompositeResourceAccessor(antFO, fsFO), database);
liquibase.setCurrentDateTimeFunction(currentDateTimeFunction);
for (Map.Entry<String, Object> entry : changeLogProperties.entrySet()) {
liquibase.setChangeLogParameter(entry.getKey(), entry.getValue());
}
return liquibase;
}
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:19,代码来源:BaseLiquibaseTask.java
示例6: performDatabaseSetupOrClean
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
private void performDatabaseSetupOrClean(boolean setup) {
try {
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
Class.forName(getJdbcDriverClassname());
Connection holdingConnection = DriverManager.getConnection(getJdbcConnectionString(), getDbUsername(), getDbPassword());
HsqlConnection hsconn = new HsqlConnection(holdingConnection);
LogFactory.getLogger().setLogLevel("warning");
Liquibase liquibase = new Liquibase(CHANGE_LOG, resourceAccessor, hsconn);
liquibase.dropAll();
if (setup) {
liquibase.update("test");
liquibase = new Liquibase(TEST_DATA_CHANGE_LOG, resourceAccessor, hsconn);
liquibase.update("test");
}
hsconn.close();
} catch (Exception ex) {
String msg = setup ? "Error during database initialization" : "Error during database clean-up";
LOG.error(msg, ex);
throw new RuntimeException(msg, ex);
}
}
开发者ID:Multifarious,项目名称:shiro-jdbi-realm,代码行数:25,代码来源:DatabaseUtils.java
示例7: testAbsolutePathChangeLog
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@Test
public void testAbsolutePathChangeLog() throws Exception {
if (database == null) {
return;
}
Enumeration<URL> urls = new JUnitResourceAccessor().toClassLoader().getResources(includedChangeLog);
URL completeChangeLogURL = urls.nextElement();
String absolutePathOfChangeLog = completeChangeLogURL.toExternalForm();
absolutePathOfChangeLog = absolutePathOfChangeLog.replaceFirst("file:\\/", "");
if (System.getProperty("os.name").startsWith("Windows ")) {
absolutePathOfChangeLog = absolutePathOfChangeLog.replace('/', '\\');
} else {
absolutePathOfChangeLog = "/" + absolutePathOfChangeLog;
}
Liquibase liquibase = createLiquibase(absolutePathOfChangeLog, new FileSystemResourceAccessor());
clearDatabase(liquibase);
liquibase.update(this.contexts);
liquibase.update(this.contexts); //try again, make sure there are no errors
clearDatabase(liquibase);
}
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:27,代码来源:AbstractIntegrationTest.java
示例8: AutoCloseableLiquibase
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
public AutoCloseableLiquibase(ManagedDataSource dataSource, String fileName) throws LiquibaseException, SQLException
{
super(fileName,
new FileSystemResourceAccessor(),
new JdbcConnection(dataSource.getConnection()));
this.dataSource = dataSource;
}
开发者ID:forge,项目名称:db-migration-addon,代码行数:8,代码来源:AutoCloseableLiquibase.java
示例9: startDB
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@BeforeClass
public static void startDB() throws ClassNotFoundException, SQLException, LiquibaseException {
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:file:target/hsql-db", "sa", "");
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(conn));
// Create Table
liquibase = new Liquibase("./src/main/resources/db/changelog/exo-search.db.changelog-1.0.0.xml",
new FileSystemResourceAccessor(),
database);
liquibase.update((String) null);
}
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:12,代码来源:PermissionsFilterIntTest.java
示例10: startDB
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@BeforeClass
public static void startDB () throws ClassNotFoundException, SQLException, LiquibaseException {
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:file:target/hsql-db", "sa", "");
Database database = DatabaseFactory.getInstance()
.findCorrectDatabaseImplementation(new JdbcConnection(conn));
//Create Table
liquibase = new Liquibase("./src/main/resources/db/changelog/exo-search.db.changelog-1.0.0.xml",
new FileSystemResourceAccessor(), database);
liquibase.update((String) null);
}
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:12,代码来源:SiteFilterIntTest.java
示例11: startDB
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@BeforeClass
public static void startDB () throws ClassNotFoundException, SQLException, LiquibaseException {
Class.forName("org.hsqldb.jdbcDriver");
conn = DriverManager.getConnection("jdbc:hsqldb:file:target/hsql-db", "sa", "");
Database database = DatabaseFactory.getInstance()
.findCorrectDatabaseImplementation(new JdbcConnection(conn));
//Create Table
liquibase = new Liquibase("./src/main/resources/db/changelog/exo-search.db.changelog-1.0.0.xml",
new FileSystemResourceAccessor(), database);
liquibase.update((String) null);
}
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:16,代码来源:AbstractDAOTest.java
示例12: setupHsqlDb
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
/**
* Setup hsql db.
*
* @param dbName the db name
* @param path the path
* @param changeLogPath the change log path
* @throws SQLException the SQL exception
* @throws LiquibaseException the liquibase exception
*/
private void setupHsqlDb(String dbName, String path, String changeLogPath) throws SQLException, LiquibaseException {
Server server = new Server();
server.setLogWriter(new PrintWriter(System.out));
server.setErrWriter(new PrintWriter(System.out));
server.setSilent(true);
server.setDatabaseName(0, dbName);
server.setDatabasePath(0, "file:" + path);
server.start();
BasicDataSource ds = UtilityMethods.getDataSourceFromConf(conf);
Liquibase liquibase = new Liquibase(UserConfigLoader.class.getResource(changeLogPath).getFile(),
new FileSystemResourceAccessor(), new HsqlConnection(ds.getConnection()));
liquibase.update("");
}
开发者ID:apache,项目名称:lens,代码行数:24,代码来源:TestUserConfigLoader.java
示例13: executeChangelogs
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
private void executeChangelogs(Connection conn, String changelog) throws LiquibaseException {
Liquibase liquibase = new Liquibase(
changelog,
new FileSystemResourceAccessor(),
new JdbcConnection(conn));
// all contexts will be applied
Contexts contexts = new Contexts();
// execute update
liquibase.update(contexts);
}
开发者ID:panifex,项目名称:panifex-platform,代码行数:13,代码来源:RepositoryTestSupport.java
示例14: contextInitialized
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@Override
public void contextInitialized(final ServletContextEvent sce)
{
Liquibase liquibase;
try (Connection conn = getConnection())
{
final String masterPath = sce.getServletContext()
.getRealPath(new File("/WEB-INF/classes/", ContextListener.MASTER_XML).getPath());
ContextListener.logger.info("Initialising liquibase");
final File masterFile = new File(masterPath);
final File baseDir = masterFile.getParentFile().getParentFile();
liquibase = new Liquibase(ContextListener.MASTER_XML,
new FileSystemResourceAccessor(baseDir.getCanonicalPath()), new JdbcConnection(conn));
liquibase.update("");
ContextListener.logger.info("Liquibase has completed successfully");
}
catch (LiquibaseException | NamingException | SQLException | IOException e)
{
ContextListener.logger.info("Liquibase failed.");
ContextListener.logger.error(e, e);
}
}
开发者ID:bsutton,项目名称:scoutmaster,代码行数:29,代码来源:ContextListener.java
示例15: initLiquibase
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
public static void initLiquibase() throws LiquibaseException, SQLException
{
final Liquibase liquibase = new Liquibase(DatabaseProvider.MASTER_XML, new FileSystemResourceAccessor(),
new JdbcConnection(DatabaseProvider.getConnection()));
liquibase.update("");
}
开发者ID:bsutton,项目名称:scoutmaster,代码行数:8,代码来源:DatabaseProvider.java
示例16: finalise
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@After
public void finalise() throws LiquibaseException, SQLException
{
final Liquibase liquibase = new Liquibase(DatabaseProvider.MASTER_XML, new FileSystemResourceAccessor(),
new JdbcConnection(DatabaseProvider.getConnection()));
liquibase.update("");
}
开发者ID:bsutton,项目名称:scoutmaster,代码行数:8,代码来源:DatabaseProvider.java
示例17: parseAndGenerate
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor("src/test/java");
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(changeLogFile, resourceAccessor).parse(changeLogFile,
changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
List<String> expectedQuery = new ArrayList<String>();
// expectedQuery.add("ALTER TABLE addcheck ADD CONSTRAINT tom_check CHECK(id between 0 and 5 ) DEFERRABLE INITIALLY DEFERRED DISABLE");
// expectedQuery.add("ALTER TABLE addcheck ADD CONSTRAINT tom_check1 CHECK(id between 10 and 15) ENABLE");
expectedQuery.add("ALTER TABLE LBUSER.addcheck ADD CHECK(id between 0 and 5 ) DEFERRABLE INITIALLY DEFERRED DISABLE");
ChangeSet changeSet = changeSets.get(1);
Change change = changeSet.getChanges().get(0);
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
assertEquals(expectedQuery.get(0), sql[0].toSql());
}
开发者ID:liquibase,项目名称:liquibase-oracle,代码行数:31,代码来源:AddCheckChangeTest.java
示例18: parseAndGenerate
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor("src/test/java");
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance()
.getParser(changeLogFile, resourceAccessor)
.parse(changeLogFile,changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
assertEquals( "number of changesets in the " + changeLogFile + " is incorrect", 2, changeSets.size() );
ChangeSet changeSet = changeSets.get(1);
assertEquals("Wrong number of changes found in changeset", 1, changeSet.getChanges().size());
Change change = changeSet.getChanges().get(0);
List<String> expectedQueries = new ArrayList<String>();
expectedQueries.add("GRANT SELECT,UPDATE,INSERT,DELETE ON LIQUIBASE.addgrant TO SYSTEM");
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
assertEquals( "wrong number of statements generated", expectedQueries.size(), sql.length );
assertEquals(expectedQueries.get(0), sql[0].toSql());
}
开发者ID:liquibase,项目名称:liquibase-oracle,代码行数:32,代码来源:GrantObjectPermissionChangeTest.java
示例19: parseAndGenerate
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
@Test
public void parseAndGenerate() throws Exception {
if (connection == null) {
return;
}
Database database = liquiBase.getDatabase();
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor("src/test/java");
ChangeLogParameters changeLogParameters = new ChangeLogParameters();
DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance()
.getParser(changeLogFile, resourceAccessor)
.parse(changeLogFile,changeLogParameters, resourceAccessor);
changeLog.validate(database);
List<ChangeSet> changeSets = changeLog.getChangeSets();
assertEquals( "number of changesets in the " + changeLogFile + " is incorrect", 3, changeSets.size() );
ChangeSet changeSet = changeSets.get(2);
assertEquals("Wrong number of changes found in changeset", 1, changeSet.getChanges().size());
Change change = changeSet.getChanges().get(0);
List<String> expectedQueries = new ArrayList<String>();
expectedQueries.add("REVOKE UPDATE,INSERT,DELETE ON LIQUIBASE.addgrant FROM SYSTEM");
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(change.generateStatements(database)[0], database);
assertEquals( "wrong number of statements generated", expectedQueries.size(), sql.length );
assertEquals(expectedQueries.get(0), sql[0].toSql());
}
开发者ID:liquibase,项目名称:liquibase-oracle,代码行数:32,代码来源:RevokeObjectPermissionChangeTest.java
示例20: run
import liquibase.resource.FileSystemResourceAccessor; //导入依赖的package包/类
public void run() throws Exception {
logger.info("Checking if database is up-to-date...");
ApplicationConfig dsConfig = config.getConfig("db." + dbName + ".datasource");
String url = dsConfig.getString("jdbcUrl");
String user = dsConfig.getString("user");
String password = dsConfig.getString("password");
Connection connection = DriverManager.getConnection(url + "?user=" + user + "&password=" + password);
String changelog = config.getString("db." + dbName + ".changelog");
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
Liquibase liquibase = new Liquibase(changelog, new FileSystemResourceAccessor(), database);
List<ChangeSet> changeSets = liquibase.listUnrunChangeSets(null);
if (changeSets.size() > 0) {
logger.info("Applying {} pending changeset(s).", changeSets.size());
liquibase.update(null);
//TODO: Abstract class generator away from here!
Iterator<MetamodelGenerator> iterator = ServiceLoader.load(MetamodelGenerator.class).iterator();
MetamodelGenerator gen = iterator.next();
if (iterator.hasNext()) {
throw new Exception("More than one ClassGenerators found on classpath.");
}
gen.generate(connection);
} else {
logger.info("All changesets already applied; no synchronization needed.");
}
}
开发者ID:gzlabs,项目名称:hightide,代码行数:29,代码来源:DatabaseSynchronizer.java
注:本文中的liquibase.resource.FileSystemResourceAccessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论