common/src/main/java/gr/ntua/ece/cslab/selis/bda/common/storage/connectors/ConnectorFactory.java
public static String createNewDatabaseWithSchemas(String fs, String username, String password,
                                                      Configuration configuration, String owner, String dbname,
                                                      Vector<String> schemas) throws SystemConnectorException, UnsupportedOperationException {
        String databaseUrl;
        int connectorType = ConnectorFactory.getConnectorType(fs);

        if (connectorType == ConnectorFactory.CONNECTOR_HDFS_TYPE) {
            throw new UnsupportedOperationException("Creating a database in HDFS is not supported.");
        } else if (connectorType == ConnectorFactory.CONNECTOR_HBASE_TYPE) {
            try {
                databaseUrl = HBaseConnector.createNamespace(fs, username, password, configuration, dbname);
            } catch (Exception e) {
                e.printStackTrace();
                throw new SystemConnectorException("Could not create HBase namespace.");
            }
        } else if (connectorType == ConnectorFactory.CONNECTOR_POSTGRES_TYPE) {
            // 0. Create new database.
            try {
                databaseUrl = PostgresqlConnector.createDatabase(
                    fs, username, password, owner, dbname);
            } catch (SQLException e) {
                e.printStackTrace();
                throw new SystemConnectorException("Could not create Postgresql database.");
            }
            // 1. Create schemas into the new database.
            if (!(schemas==null)) {
                for (String schema : schemas) {
                    try {
                        PostgresqlConnector.createSchema(databaseUrl, username, password, owner, schema);
                    } catch (SQLException e) {
                        e.printStackTrace();
                        throw new SystemConnectorException("Could not create Postgresql schema.");
                    }
                }
            }
        } else {
            throw new UnsupportedOperationException("Creating a database in local FS is not supported.");
        }

        return databaseUrl;
    }
/** Creates a new database and specified schemas.
     *  Returns the jdbcUrl of the new database. **/
Creates a new database and specified schemas.
Returns the jdbcUrl of the new database.
Creates a new database and specified schemas . Returns the jdbcUrl of the new database .
public static String createNewDatabaseWithSchemas(String fs, String username, String password,
                                                      Configuration configuration, String owner, String dbname,
                                                      Vector<String> schemas) throws SystemConnectorException, UnsupportedOperationException {
        String databaseUrl;
        int connectorType = ConnectorFactory.getConnectorType(fs);
        if (connectorType == ConnectorFactory.CONNECTOR_HDFS_TYPE) {
            throw new UnsupportedOperationException("Creating a database in HDFS is not supported.");
        } else if (connectorType == ConnectorFactory.CONNECTOR_HBASE_TYPE) {
            try {
                databaseUrl = HBaseConnector.createNamespace(fs, username, password, configuration, dbname);
            } catch (Exception e) {
                e.printStackTrace();
                throw new SystemConnectorException("Could not create HBase namespace.");
            }
        } else if (connectorType == ConnectorFactory.CONNECTOR_POSTGRES_TYPE) {
            try {
                databaseUrl = PostgresqlConnector.createDatabase(
                    fs, username, password, owner, dbname);
            } catch (SQLException e) {
                e.printStackTrace();
                throw new SystemConnectorException("Could not create Postgresql database.");
            }
            if (!(schemas==null)) {
                for (String schema : schemas) {
                    try {
                        PostgresqlConnector.createSchema(databaseUrl, username, password, owner, schema);
                    } catch (SQLException e) {
                        e.printStackTrace();
                        throw new SystemConnectorException("Could not create Postgresql schema.");
                    }
                }
            }
        } else {
            throw new UnsupportedOperationException("Creating a database in local FS is not supported.");
        }
        return databaseUrl;
    }
public static String createNewDatabaseWithSchemas ( String fs , String username , String password , Configuration configuration , String owner , String dbname , Vector < String > schemas ) throws SystemConnectorException , UnsupportedOperationException { String databaseUrl ; int connectorType = ConnectorFactory . getConnectorType ( fs ) ; if ( connectorType == ConnectorFactory . CONNECTOR_HDFS_TYPE ) { throw new UnsupportedOperationException ( "Creating a database in HDFS is not supported." ) ; } else if ( connectorType == ConnectorFactory . CONNECTOR_HBASE_TYPE ) { try { databaseUrl = HBaseConnector . createNamespace ( fs , username , password , configuration , dbname ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; throw new SystemConnectorException ( "Could not create HBase namespace." ) ; } } else if ( connectorType == ConnectorFactory . CONNECTOR_POSTGRES_TYPE ) { try { databaseUrl = PostgresqlConnector . createDatabase ( fs , username , password , owner , dbname ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; throw new SystemConnectorException ( "Could not create Postgresql database." ) ; } if ( ! ( schemas == null ) ) { for ( String schema : schemas ) { try { PostgresqlConnector . createSchema ( databaseUrl , username , password , owner , schema ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; throw new SystemConnectorException ( "Could not create Postgresql schema." ) ; } } } } else { throw new UnsupportedOperationException ( "Creating a database in local FS is not supported." ) ; } return databaseUrl ; }
Creates a new database and specified schemas.
Creates a new database and specified schemas .
// 0. Create new database. // 1. Create schemas into the new database.