Search in sources :

Example 1 with JdbcMetaSchemasResult

use of org.apache.ignite.client.proto.query.event.JdbcMetaSchemasResult in project ignite-3 by apache.

the class JdbcDatabaseMetadata method getSchemas.

/**
 * {@inheritDoc}
 */
@Override
public ResultSet getSchemas(String catalog, String schemaPtrn) throws SQLException {
    conn.ensureNotClosed();
    final List<JdbcColumnMeta> meta = asList(new JdbcColumnMeta("TABLE_SCHEM", String.class), new JdbcColumnMeta("TABLE_CATALOG", String.class));
    if (!isValidCatalog(catalog)) {
        return new JdbcResultSet(Collections.emptyList(), meta);
    }
    JdbcMetaSchemasResult res = conn.handler().schemasMetaAsync(new JdbcMetaSchemasRequest(schemaPtrn)).join();
    if (!res.hasResults()) {
        throw IgniteQueryErrorCode.createJdbcSqlException(res.err(), res.status());
    }
    List<List<Object>> rows = new LinkedList<>();
    for (String schema : res.schemas()) {
        List<Object> row = new ArrayList<>(2);
        row.add(schema);
        row.add(CATALOG_NAME);
        rows.add(row);
    }
    return new JdbcResultSet(rows, meta);
}
Also used : JdbcMetaSchemasRequest(org.apache.ignite.client.proto.query.event.JdbcMetaSchemasRequest) ArrayList(java.util.ArrayList) JdbcColumnMeta(org.apache.ignite.client.proto.query.event.JdbcColumnMeta) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) LinkedList(java.util.LinkedList) List(java.util.List) JdbcMetaSchemasResult(org.apache.ignite.client.proto.query.event.JdbcMetaSchemasResult) LinkedList(java.util.LinkedList)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 JdbcColumnMeta (org.apache.ignite.client.proto.query.event.JdbcColumnMeta)1 JdbcMetaSchemasRequest (org.apache.ignite.client.proto.query.event.JdbcMetaSchemasRequest)1 JdbcMetaSchemasResult (org.apache.ignite.client.proto.query.event.JdbcMetaSchemasResult)1