Package org.rhq.core.db.setup

Examples of org.rhq.core.db.setup.DBSetup$ErrorHandler


            return;
        } else {
            conn.close();
        }

        DBSetup dbsetup = new DBSetup(getTestDatabaseConnectionUrl(db), getTestDatabaseConnectionUsername(db),
            getTestDatabaseConnectionPassword(db), false);

        try {
            dbsetup.setup("small-dbsetup.xml");

            conn = getConnection(db);
            DatabaseType dbtype = DatabaseTypeFactory.getDatabaseType(conn);

            assert dbtype.checkTableExists(conn, "TEST_SMALL");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "ID");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYLONG");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYBIGDEC");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYLONGVARCHAR");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYDOUBLE");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYBOOLEAN");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYBYTES");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYVARCHAR2");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYCLOB");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYBLOB");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYCHAR");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYSMALLINT");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYTIMESTAMP");

            ResultSet results = conn.prepareCall("SELECT MYVARCHAR2 FROM TEST_SMALL").executeQuery();
            results.next();
            assert "abc-myvarchar2".equals(results.getString("MYVARCHAR2"));
            results.close();
        } finally {
            try {
                dbsetup.uninstall("small-dbsetup.xml");
            } catch (Exception e) {
                System.err.println("Cannot uninstall the test schema");
            }
        }
View Full Code Here


            return;
        } else {
            conn.close();
        }

        DBSetup dbsetup = new DBSetup(getTestDatabaseConnectionUrl(db), getTestDatabaseConnectionUsername(db),
            getTestDatabaseConnectionPassword(db), false);

        dbsetup.setup("small-dbsetup.xml");

        DatabaseType dbtype;

        // get the connection, make sure the setup worked, and then uninstall the schema
        try {
            conn = getConnection(db);
            dbtype = DatabaseTypeFactory.getDatabaseType(conn);
            assert dbtype.checkTableExists(conn, "TEST_SMALL");
        } finally {
            dbsetup.uninstall("small-dbsetup.xml");
        }

        // make sure the uninstall worked
        try {
            boolean result = dbtype.checkTableExists(conn, "TEST_SMALL");
View Full Code Here

            return;
        } else {
            conn.close();
        }

        DBSetup dbsetup = new DBSetup(getTestDatabaseConnectionUrl(db), getTestDatabaseConnectionUsername(db),
            getTestDatabaseConnectionPassword(db), false);

        try {
            dbsetup.setup("small-dbsetup.xml");

            conn = getConnection(db);
            DatabaseType dbtype = DatabaseTypeFactory.getDatabaseType(conn);

            assert dbtype.checkTableExists(conn, "TEST_SMALL");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "ID");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYLONG");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYBIGDEC");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYLONGVARCHAR");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYDOUBLE");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYBOOLEAN");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYBYTES");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYVARCHAR2");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYCLOB");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYBLOB");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYCHAR");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYSMALLINT");
            assert dbtype.checkColumnExists(conn, "TEST_SMALL", "MYTIMESTAMP");

            ResultSet results = conn.prepareCall("SELECT MYVARCHAR2 FROM TEST_SMALL").executeQuery();
            results.next();
            assert "abc-myvarchar2".equals(results.getString("MYVARCHAR2"));
            results.close();
        } finally {
            try {
                dbsetup.uninstall("small-dbsetup.xml");
            } catch (Exception e) {
                System.err.println("Cannot uninstall the test schema");
            }
        }
View Full Code Here

        conn = getConnection(db);
        if (conn == null) {
            return;
        }

        DBSetup dbsetup = new DBSetup(getTestDatabaseConnectionUrl(db), getTestDatabaseConnectionUsername(db),
            getTestDatabaseConnectionPassword(db), false);

        dbsetup.setup("small-dbsetup.xml");

        DatabaseType dbtype;

        // get the connection, make sure the setup worked, and then uninstall the schema
        try {
            conn = getConnection(db);
            dbtype = DatabaseTypeFactory.getDatabaseType(conn);
            assert dbtype.checkTableExists(conn, "TEST_SMALL");
        } finally {
            dbsetup.uninstall("small-dbsetup.xml");
        }

        // make sure the uninstall worked
        try {
            boolean result = dbtype.checkTableExists(conn, "TEST_SMALL");
View Full Code Here

            // extract the dbsetup files which are located in the dbutils jar
            String dbsetupSchemaXmlFile = extractDatabaseXmlFile("db-schema-combined.xml", props, serverDetails, logDir);
            String dbsetupDataXmlFile = extractDatabaseXmlFile("db-data-combined.xml", props, serverDetails, logDir);

            // first uninstall any old existing schema, then create the tables then insert the data
            DBSetup dbsetup = new DBSetup(dbUrl, userName, password);
            dbsetup.uninstall(dbsetupSchemaXmlFile);
            dbsetup.setup(dbsetupSchemaXmlFile);
            dbsetup.setup(dbsetupDataXmlFile, null, true, false);
        } catch (Exception e) {
            LOG.fatal("Cannot install the database schema - the server will not run properly.", e);
            throw e;
        }
    }
View Full Code Here

                old_sysprops.put(env_var.getKey(), old_value);
            }
        }

        try {
            DBSetup dbs = new DBSetup(jdbcUrl, jdbcUser, jdbcPassword);

            if (uninstall) {
                dbs.uninstall(xmlFile.getAbsolutePath());
            } else if (exportXml) {
                dbs.export(xmlFile.getAbsolutePath());
            } else if (table == null) {
                dbs.setup(xmlFile.getAbsolutePath());
            } else {
                dbs.setup(xmlFile.getAbsolutePath(), table, dataOnly, doDelete);
            }
        } catch (Exception e) {
            throw new BuildException(e);
        } finally {
            // revert back to the old system properties
View Full Code Here

        DBReset dbReset = new DBReset();
        dbReset.performDBReset(DB_TYPE_MAPPING, DB_URL, DB_NAME, USERNAME, ADMIN_USERNAME, ADMIN_PASSWORD);
    }

    private void installSchemaAndData(String jonVersion) throws Exception {
        DBSetup dbsetup = new DBSetup(DB_URL, USERNAME, PASSWORD);
        File schemaFile = getSchemaFile(jonVersion);
        dbsetup.setup(schemaFile.getAbsolutePath());
        File dataFile = getDataFile(jonVersion);
        dbsetup.setup(dataFile.getAbsolutePath());
    }
View Full Code Here

            dataFileResourcePath = "db-data-combined.xml";
        }

        TestDatasourceConfiguration testDs = getTestDatasourceConfiguration();
       
        DBSetup dbsetup = new DBSetup(testDs.connectionUrl, testDs.userName, testDs.password);
        dbsetup.setup(schemaFileResourcePath);
        dbsetup.setup(dataFileResourcePath);
    }
View Full Code Here

            upgradeFile.delete();
        }
    }

    private void setup() throws Exception {
        DBSetup dbSetup = new DBSetup(connection);

        File minimalSchema = getFileFromResource(MINIMAL_VERSION_OF_SCHEMA, getClass().getClassLoader());
        File currentSchema = getFileFromDbUtils("db-schema-combined.xml");
       
        try {
            replaceTokensInFile(minimalSchema);
            replaceTokensInFile(currentSchema);
            dbSetup.uninstall(currentSchema.getAbsolutePath());
            dbSetup.setup(minimalSchema.getAbsolutePath());
        } finally {
            minimalSchema.delete();
            currentSchema.delete();
        }

        File data = getFileFromResource(MINIMAL_VERSION_OF_DATA, getClass().getClassLoader());

        try {
            replaceTokensInFile(data);
            dbSetup.setup(data.getAbsolutePath(), null, true, false);
        } finally {
            data.delete();
        }
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.db.setup.DBSetup$ErrorHandler

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.