本文整理汇总了Java中liquibase.resource.FileSystemResourceAccessor类的典型用法代码示例。如果您正苦于以下问题:Java FileSystemResourceAccessor类的具体用法?Java FileSystemResourceAccessor怎么用?Java FileSystemResourceAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemResourceAccessor类属于liquibase.resource包,在下文中一共展示了FileSystemResourceAccessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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("");
}
示例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);
}
示例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);
}
}
示例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("");
}