Search in sources :

Example 1 with JdbcMetaColumnsRequest

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

the class JdbcDatabaseMetadata method getColumns.

/**
 * {@inheritDoc}
 */
@Override
public ResultSet getColumns(String catalog, String schemaPtrn, String tblNamePtrn, String colNamePtrn) throws SQLException {
    conn.ensureNotClosed();
    final List<JdbcColumnMeta> meta = asList(// 1
    new JdbcColumnMeta("TABLE_CAT", String.class), // 2
    new JdbcColumnMeta("TABLE_SCHEM", String.class), // 3
    new JdbcColumnMeta("TABLE_NAME", String.class), // 4
    new JdbcColumnMeta("COLUMN_NAME", String.class), // 5
    new JdbcColumnMeta("DATA_TYPE", Short.class), // 6
    new JdbcColumnMeta("TYPE_NAME", String.class), // 7
    new JdbcColumnMeta("COLUMN_SIZE", Integer.class), // 8
    new JdbcColumnMeta("BUFFER_LENGTH", Integer.class), // 9
    new JdbcColumnMeta("DECIMAL_DIGITS", Integer.class), // 10
    new JdbcColumnMeta("NUM_PREC_RADIX", Short.class), // 11
    new JdbcColumnMeta("NULLABLE", Short.class), // 12
    new JdbcColumnMeta("REMARKS", String.class), // 13
    new JdbcColumnMeta("COLUMN_DEF", String.class), // 14
    new JdbcColumnMeta("SQL_DATA_TYPE", Integer.class), // 15
    new JdbcColumnMeta("SQL_DATETIME_SUB", Integer.class), // 16
    new JdbcColumnMeta("CHAR_OCTET_LENGTH", Integer.class), // 17
    new JdbcColumnMeta("ORDINAL_POSITION", Integer.class), // 18
    new JdbcColumnMeta("IS_NULLABLE", String.class), // 19
    new JdbcColumnMeta("SCOPE_CATLOG", String.class), // 20
    new JdbcColumnMeta("SCOPE_SCHEMA", String.class), // 21
    new JdbcColumnMeta("SCOPE_TABLE", String.class), // 22
    new JdbcColumnMeta("SOURCE_DATA_TYPE", Short.class), // 23
    new JdbcColumnMeta("IS_AUTOINCREMENT", String.class), // 24
    new JdbcColumnMeta("IS_GENERATEDCOLUMN", String.class));
    if (!isValidCatalog(catalog)) {
        return new JdbcResultSet(Collections.emptyList(), meta);
    }
    JdbcMetaColumnsResult res = conn.handler().columnsMetaAsync(new JdbcMetaColumnsRequest(schemaPtrn, tblNamePtrn, colNamePtrn)).join();
    if (!res.hasResults()) {
        throw IgniteQueryErrorCode.createJdbcSqlException(res.err(), res.status());
    }
    List<List<Object>> rows = new LinkedList<>();
    for (int i = 0; i < res.meta().size(); ++i) {
        rows.add(columnRow(res.meta().get(i), i + 1));
    }
    return new JdbcResultSet(rows, meta);
}
Also used : JdbcMetaColumnsResult(org.apache.ignite.client.proto.query.event.JdbcMetaColumnsResult) 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) JdbcMetaColumnsRequest(org.apache.ignite.client.proto.query.event.JdbcMetaColumnsRequest) 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 JdbcMetaColumnsRequest (org.apache.ignite.client.proto.query.event.JdbcMetaColumnsRequest)1 JdbcMetaColumnsResult (org.apache.ignite.client.proto.query.event.JdbcMetaColumnsResult)1