Example usage for java.sql Connection setCatalog

List of usage examples for java.sql Connection setCatalog

Introduction

In this page you can find the example usage for java.sql Connection setCatalog.

Prototype

void setCatalog(String catalog) throws SQLException;

Source Link

Document

Sets the given catalog name in order to select a subspace of this Connection object's database in which to work.

Usage

From source file:org.verdictdb.core.scramblingquerying.TpchScrambleQueryForAllDatabasesTest.java

private static Connection setupMysql() throws SQLException, VerdictDBDbmsException {
    String mysqlConnectionString = String.format("jdbc:mysql://%s?autoReconnect=true&useSSL=false", MYSQL_HOST);
    String vcMysqlConnectionString = String.format(
            "jdbc:verdict:mysql://%s?autoReconnect=true&useSSL=false&"
                    + "verdictdbmetaschema=%s&verdictdbtempschema=%s",
            MYSQL_HOST, VERDICT_META_SCHEMA, VERDICT_TEMP_SCHEMA);
    Connection conn = DatabaseConnectionHelpers.setupMySql(mysqlConnectionString, MYSQL_USER, MYSQL_PASSWORD,
            SCHEMA_NAME);//from   www .  j a  va 2  s  . com
    Connection vc = DriverManager.getConnection(vcMysqlConnectionString, MYSQL_USER, MYSQL_PASSWORD);
    conn.setCatalog(SCHEMA_NAME);
    vc.setCatalog(SCHEMA_NAME);
    connMap.put("mysql", conn);
    vcMap.put("mysql", vc);
    schemaMap.put("mysql", MYSQL_DATABASE + ".");

    conn.createStatement()
            .execute(String.format("CREATE SCHEMA IF NOT EXISTS %s", options.getVerdictTempSchemaName()));
    vc.createStatement().execute(
            String.format("CREATE SCRAMBLE %s.lineitem_scramble FROM %s.lineitem", SCHEMA_NAME, SCHEMA_NAME));
    return conn;
}