Package liquibase.database.jvm

Examples of liquibase.database.jvm.JdbcConnection


        Liquibase liquibase = new Liquibase((String) null, new ClassLoaderResourceAccessor(), database);

        Database hibernateDatabase = new HibernateClassicDatabase();
//        hibernateDatabase.setDefaultSchemaName("PUBLIC");
//        hibernateDatabase.setDefaultCatalogName("TESTDB");
        hibernateDatabase.setConnection(new JdbcConnection(new HibernateConnection("hibernate:classic:" + HIBERNATE_CONFIG_FILE)));

        DiffResult diffResult = liquibase.diff(hibernateDatabase, database, compareControl);

        assertTrue(diffResult.getMissingObjects().size() > 0);
View Full Code Here


        export.execute(true, true, false, false);

        Database hibernateDatabase = new HibernateClassicDatabase();
        hibernateDatabase.setDefaultSchemaName("PUBLIC");
        hibernateDatabase.setDefaultCatalogName("TESTDB");
        hibernateDatabase.setConnection(new JdbcConnection(new HibernateConnection("hibernate:classic:" + HIBERNATE_CONFIG_FILE)));

        Liquibase liquibase = new Liquibase((String) null, new ClassLoaderResourceAccessor(), database);
        DiffResult diffResult = liquibase.diff(hibernateDatabase, database, compareControl);

        ignoreDatabaseChangeLogTable(diffResult);
View Full Code Here

        Liquibase liquibase = new Liquibase((String) null, new ClassLoaderResourceAccessor(), database);

        Database hibernateDatabase = new HibernateClassicDatabase();
        hibernateDatabase.setDefaultSchemaName("PUBLIC");
        hibernateDatabase.setDefaultCatalogName("TESTDB");
        hibernateDatabase.setConnection(new JdbcConnection(new HibernateConnection("hibernate:classic:" + HIBERNATE_CONFIG_FILE)));

        DiffResult diffResult = liquibase.diff(hibernateDatabase, database, compareControl);

        assertTrue(diffResult.getMissingObjects().size() > 0);

        File outFile = File.createTempFile("lb-test", ".xml");
        OutputStream outChangeLog = new FileOutputStream(outFile);
        String changeLogString = toChangeLog(diffResult);
        outChangeLog.write(changeLogString.getBytes("UTF-8"));
        outChangeLog.close();

        log.info("Changelog:\n" + changeLogString);

        liquibase = new Liquibase(outFile.toString(), new FileSystemResourceAccessor(), database);
        StringWriter stringWriter = new StringWriter();
        liquibase.update((String) null, stringWriter);
        log.info(stringWriter.toString());
        liquibase.update((String) null);

        long currentTimeMillis = System.currentTimeMillis();
        Connection connection2 = DriverManager.getConnection("jdbc:hsqldb:mem:TESTDB2" + currentTimeMillis, "SA", "");
        Database database2 = new HsqlDatabase();
        database2.setConnection(new JdbcConnection(connection2));

        Configuration cfg = new Configuration();
        cfg.configure(HIBERNATE_CONFIG_FILE);
        cfg.getProperties().remove(Environment.DATASOURCE);
        cfg.setProperty(Environment.URL, "jdbc:hsqldb:mem:TESTDB2" + currentTimeMillis);
View Full Code Here

//        });
//    }

    @Test
    public void testHibernateUrlSimple() throws DatabaseException {
        conn = new JdbcConnection(new HibernateConnection("hibernate:classic:com/example/pojo/Hibernate.cfg.xml"));
        db.setConnection(conn);
        assertNotNull(db.getConfiguration().getClassMapping(AuctionItem.class.getName()));
        assertNotNull(db.getConfiguration().getClassMapping(Watcher.class.getName()));
    }
View Full Code Here

    }


    @Test
    public void testCustomConfigMustHaveItemClassMapping() throws DatabaseException {
        conn = new JdbcConnection(new HibernateConnection("hibernate:classic:" + CUSTOMCONFIG_CLASS));
        db.setConnection(conn);
        assertNotNull(db.getConfiguration().getClassMapping(Item.class.getName()));
    }
View Full Code Here

        db.close();
    }

    @Test
    public void testSpringUrlSimple() throws DatabaseException {
        conn = new JdbcConnection(new HibernateConnection("hibernate:spring:spring.ctx.xml?bean=sessionFactory"));
        db.setConnection(conn);
        assertNotNull(db.getConfiguration().getClassMapping(AuctionItem.class.getName()));
        assertNotNull(db.getConfiguration().getClassMapping(Watcher.class.getName()));
    }
View Full Code Here

            Connection connection = driver.connect(getUrl(), connectionProps);
            if(connection == null) {
                throw new BuildException("Unable to create Liquibase Database instance. Could not connect to the database.");
            }
            JdbcConnection jdbcConnection = new JdbcConnection(connection);

            Database database = databaseFactory.findCorrectDatabaseImplementation(jdbcConnection);

            String schemaName = getDefaultSchemaName();
            if (schemaName != null) {
View Full Code Here

            for (Database database : allDatabases) {
                ConnectionConfigurationFactory configurationFactory = ConnectionConfigurationFactory.getInstance();
                for (ConnectionSupplier connectionSupplier : configurationFactory.getConfigurations(database)) {
                    try {
                        Connection connection = connectionSupplier.openConnection();
                        database.setConnection(new JdbcConnection(connection));
                        break;
                    } catch (SQLException e) {
                        System.out.println("Cannot connect to "+connectionSupplier.getJdbcUrl());
                        database.setConnection(new OfflineConnection("offline:"+database.getShortName()));
                    }
View Full Code Here

    @Before
    public void setUp() throws Exception {
        Class.forName("org.hsqldb.jdbc.JDBCDriver");
        connection = DriverManager.getConnection("jdbc:hsqldb:mem:TESTDB" + System.currentTimeMillis()+"-"+(run++), "SA", "");
        database = new HsqlDatabase();
        database.setConnection(new JdbcConnection(connection));

        Set<Class<? extends DatabaseObject>> typesToInclude = new HashSet<Class<? extends DatabaseObject>>();
        typesToInclude.add(Table.class);
        typesToInclude.add(Column.class);
        typesToInclude.add(PrimaryKey.class);
View Full Code Here

        Liquibase liquibase = new Liquibase((String) null, new ClassLoaderResourceAccessor(), database);

        Database hibernateDatabase = new HibernateSpringDatabase();
        hibernateDatabase.setDefaultSchemaName("PUBLIC");
        hibernateDatabase.setDefaultCatalogName("TESTDB");
        hibernateDatabase.setConnection(new JdbcConnection(new HibernateConnection("hibernate:spring:"+ PACKAGES+ "?dialect=" + HSQLDialect.class.getName())));

        DiffResult diffResult = liquibase.diff(hibernateDatabase, database, compareControl);

        assertTrue(diffResult.getMissingObjects().size() > 0);
View Full Code Here

TOP

Related Classes of liquibase.database.jvm.JdbcConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.