Example usage for java.sql Connection setSchema

List of usage examples for java.sql Connection setSchema

Introduction

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

Prototype

void setSchema(String schema) throws SQLException;

Source Link

Document

Sets the given schema name to access.

Usage

From source file:com.netflix.metacat.connector.snowflake.SnowflakeConnectorTableService.java

@Override
protected Connection getConnection(@Nonnull @NonNull final String schema) throws SQLException {
    final Connection connection = this.dataSource.getConnection();
    connection.setSchema(connection.getCatalog());
    return connection;
}

From source file:com.splicemachine.triggers.Trigger_Create_IT.java

@Before
public void createTables() throws Exception {
    triggerDAO.dropAllTriggers(SCHEMA, "T");
    Connection conn = new TestConnection(DriverManager.getConnection(connectionString, new Properties()));
    conn.setSchema(SCHEMA.toUpperCase());
    methodWatcher.setConnection(conn);//  ww w  .ja  va2 s.  c o  m
}

From source file:com.netflix.metacat.connector.jdbc.services.JdbcConnectorTableService.java

protected Connection getConnection(@Nonnull @NonNull final String schema) throws SQLException {
    final Connection connection = this.dataSource.getConnection();
    connection.setSchema(schema);
    return connection;
}

From source file:herddb.cli.HerdDBCLI.java

private static void performBackup(final Statement statement, String schema, String file, Options options,
        final Connection connection, int dumpfetchsize) throws SQLException, Exception {
    if (file.isEmpty()) {
        println("Please provide --file option");
        failAndPrintHelp(options);/*from  w ww.  j  ava2s.co m*/
        return;
    }
    if (schema.equals("*")) {
        connection.setSchema(TableSpace.DEFAULT);
        List<String> tablespacesToDump = new ArrayList<>();
        try (ResultSet rs = statement.executeQuery("SELECT tablespace_name FROM systablespaces")) {
            while (rs.next()) {
                String tablename = rs.getString(1).toLowerCase();
                tablespacesToDump.add(tablename);
            }
        }
        for (String tableSpace : tablespacesToDump) {
            backupTableSpace(statement, tableSpace, file, tableSpace, connection, dumpfetchsize);
        }
    } else {
        backupTableSpace(statement, schema, file, null, connection, dumpfetchsize);
    }
}

From source file:com.adaptris.jdbc.connection.FailoverDatasourceTest.java

@Test
public void testInfo() throws Exception {
    Connection conn = new MyProxy();

    try {/* www.  ja  v a 2 s.  c  om*/
        try {
            conn.getMetaData();
        } catch (SQLException e) {

        }
        try {
            conn.setCatalog(conn.getCatalog());
        } catch (SQLException e) {

        }
        try {
            conn.setReadOnly(conn.isReadOnly());
        } catch (SQLException e) {

        }
        try {
            conn.setTransactionIsolation(conn.getTransactionIsolation());
        } catch (SQLException e) {

        }
        try {
            conn.setTransactionIsolation(conn.getTransactionIsolation());
        } catch (SQLException e) {

        }
        try {
            conn.getWarnings();
        } catch (SQLException e) {

        }
        try {
            conn.clearWarnings();
        } catch (SQLException e) {

        }
        try {
            conn.setHoldability(conn.getHoldability());
        } catch (SQLException e) {

        }

        try {
            conn.setSchema(conn.getSchema());
        } catch (SQLException e) {

        }

    } finally {
        JdbcUtil.closeQuietly(conn);
    }

}

From source file:org.apache.calcite.avatica.jdbc.JdbcMeta.java

protected void apply(Connection conn, ConnectionProperties connProps) throws SQLException {
    if (connProps.isAutoCommit() != null) {
        conn.setAutoCommit(connProps.isAutoCommit());
    }/*  w w  w. java 2 s.co  m*/
    if (connProps.isReadOnly() != null) {
        conn.setReadOnly(connProps.isReadOnly());
    }
    if (connProps.getTransactionIsolation() != null) {
        conn.setTransactionIsolation(connProps.getTransactionIsolation());
    }
    if (connProps.getCatalog() != null) {
        conn.setCatalog(connProps.getCatalog());
    }
    if (connProps.getSchema() != null) {
        conn.setSchema(connProps.getSchema());
    }
}