Search in sources :

Example 76 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project calcite-avatica by apache.

the class MetaResultSetTest method testGetUDTs.

@Test
public void testGetUDTs() throws SQLException {
    DatabaseMetaData metadata = getDatabaseMetadata();
    try (ResultSet rs = metadata.getUDTs(null, null, null, null)) {
        ResultSetMetaData rsMeta = rs.getMetaData();
        assertEquals(7, rsMeta.getColumnCount());
        assertColumn(rsMeta, 1, "TYPE_CAT", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 2, "TYPE_SCHEM", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 3, "TYPE_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 4, "CLASS_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 5, "DATA_TYPE", Types.INTEGER, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 6, "REMARKS", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 7, "BASE_TYPE", Types.SMALLINT, DatabaseMetaData.columnNullable);
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 77 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project calcite-avatica by apache.

the class MetaResultSetTest method testGetBestRowIdentifier.

@Test
public void testGetBestRowIdentifier() throws SQLException {
    DatabaseMetaData metadata = getDatabaseMetadata();
    try (ResultSet rs = metadata.getBestRowIdentifier(null, null, null, DatabaseMetaData.bestRowUnknown, false)) {
        ResultSetMetaData rsMeta = rs.getMetaData();
        assertEquals(8, rsMeta.getColumnCount());
        assertColumn(rsMeta, 1, "SCOPE", Types.SMALLINT, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 2, "COLUMN_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 3, "DATA_TYPE", Types.INTEGER, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 4, "TYPE_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 5, "COLUMN_SIZE", Types.INTEGER, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 6, "BUFFER_LENGTH", Types.INTEGER, DatabaseMetaData.columnNullableUnknown);
        assertColumn(rsMeta, 7, "DECIMAL_DIGITS", Types.SMALLINT, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 8, "PSEUDO_COLUMN", Types.SMALLINT, DatabaseMetaData.columnNoNulls);
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 78 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project calcite-avatica by apache.

the class MetaResultSetTest method testGetIndexInfo.

@Test
public void testGetIndexInfo() throws SQLException {
    DatabaseMetaData metadata = getDatabaseMetadata();
    try (ResultSet rs = metadata.getIndexInfo(null, null, null, false, false)) {
        ResultSetMetaData rsMeta = rs.getMetaData();
        assertEquals(13, rsMeta.getColumnCount());
        assertColumn(rsMeta, 1, "TABLE_CAT", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 2, "TABLE_SCHEM", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 3, "TABLE_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 4, "NON_UNIQUE", Types.BOOLEAN, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 5, "INDEX_QUALIFIER", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 6, "INDEX_NAME", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 7, "TYPE", Types.SMALLINT, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 8, "ORDINAL_POSITION", Types.SMALLINT, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 9, "COLUMN_NAME", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 10, "ASC_OR_DESC", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 11, "CARDINALITY", Types.BIGINT, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 12, "PAGES", Types.BIGINT, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 13, "FILTER_CONDITION", Types.VARCHAR, DatabaseMetaData.columnNullable);
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 79 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project calcite-avatica by apache.

the class MetaResultSetTest method testGetAttributes.

@Test
public void testGetAttributes() throws SQLException {
    DatabaseMetaData metadata = getDatabaseMetadata();
    try (ResultSet rs = metadata.getAttributes(null, null, null, null)) {
        ResultSetMetaData rsMeta = rs.getMetaData();
        assertEquals(21, rsMeta.getColumnCount());
        assertColumn(rsMeta, 1, "TYPE_CAT", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 2, "TYPE_SCHEM", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 3, "TYPE_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 4, "ATTR_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 5, "DATA_TYPE", Types.INTEGER, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 6, "ATTR_TYPE_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 7, "ATTR_SIZE", Types.INTEGER, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 8, "DECIMAL_DIGITS", Types.INTEGER, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 9, "NUM_PREC_RADIX", Types.INTEGER, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 10, "NULLABLE", Types.INTEGER, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 11, "REMARKS", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 12, "ATTR_DEF", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 13, "SQL_DATA_TYPE", Types.INTEGER, DatabaseMetaData.columnNullableUnknown);
        assertColumn(rsMeta, 14, "SQL_DATETIME_SUB", Types.INTEGER, DatabaseMetaData.columnNullableUnknown);
        assertColumn(rsMeta, 15, "CHAR_OCTET_LENGTH", Types.INTEGER, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 16, "ORDINAL_POSITION", Types.INTEGER, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 17, "IS_NULLABLE", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 18, "SCOPE_CATALOG", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 19, "SCOPE_SCHEMA", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 20, "SCOPE_TABLE", Types.VARCHAR, DatabaseMetaData.columnNullable);
        assertColumn(rsMeta, 21, "SOURCE_DATA_TYPE", Types.SMALLINT, DatabaseMetaData.columnNullable);
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 80 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project calcite-avatica by apache.

the class MetaResultSetTest method testGetSchemas.

@Test
public void testGetSchemas() throws SQLException {
    DatabaseMetaData metadata = getDatabaseMetadata();
    try (ResultSet rs = metadata.getSchemas(null, null)) {
        ResultSetMetaData rsMeta = rs.getMetaData();
        assertEquals(2, rsMeta.getColumnCount());
        assertColumn(rsMeta, 1, "TABLE_SCHEM", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
        assertColumn(rsMeta, 2, "TABLE_CATALOG", Types.VARCHAR, DatabaseMetaData.columnNullable);
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) ResultSet(java.sql.ResultSet) DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Aggregations

DatabaseMetaData (java.sql.DatabaseMetaData)360 ResultSet (java.sql.ResultSet)215 Connection (java.sql.Connection)169 SQLException (java.sql.SQLException)154 Test (org.junit.Test)87 Statement (java.sql.Statement)49 ResultSetMetaData (java.sql.ResultSetMetaData)42 ArrayList (java.util.ArrayList)40 PreparedStatement (java.sql.PreparedStatement)38 IOException (java.io.IOException)26 Properties (java.util.Properties)25 HashSet (java.util.HashSet)16 PhoenixDatabaseMetaData (org.apache.phoenix.jdbc.PhoenixDatabaseMetaData)16 HashMap (java.util.HashMap)15 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)15 PrintWriter (java.io.PrintWriter)10 Savepoint (java.sql.Savepoint)10 List (java.util.List)10 Map (java.util.Map)9 DataSource (javax.sql.DataSource)9