Search in sources :

Example 11 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project druid by druid-io.

the class DruidAvaticaHandlerTest method testDatabaseMetaDataColumns.

@Test
public void testDatabaseMetaDataColumns() throws Exception {
    final DatabaseMetaData metaData = client.getMetaData();
    Assert.assertEquals(ImmutableList.of(ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "__time"), Pair.of("DATA_TYPE", Types.TIMESTAMP), Pair.of("TYPE_NAME", "TIMESTAMP"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "cnt"), Pair.of("DATA_TYPE", Types.BIGINT), Pair.of("TYPE_NAME", "BIGINT"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "dim1"), Pair.of("DATA_TYPE", Types.VARCHAR), Pair.of("TYPE_NAME", "VARCHAR"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "dim2"), Pair.of("DATA_TYPE", Types.VARCHAR), Pair.of("TYPE_NAME", "VARCHAR"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "m1"), Pair.of("DATA_TYPE", Types.FLOAT), Pair.of("TYPE_NAME", "FLOAT"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "unique_dim1"), Pair.of("DATA_TYPE", Types.OTHER), Pair.of("TYPE_NAME", "OTHER"), Pair.of("IS_NULLABLE", "NO"))), getRows(metaData.getColumns(null, "dr_id", "foo", null), ImmutableSet.of("IS_NULLABLE", "TABLE_NAME", "TABLE_SCHEM", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME")));
}
Also used : DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 12 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project druid by druid-io.

the class DruidAvaticaHandlerTest method testDatabaseMetaDataCatalogs.

@Test
public void testDatabaseMetaDataCatalogs() throws Exception {
    final DatabaseMetaData metaData = client.getMetaData();
    Assert.assertEquals(ImmutableList.of(ROW(Pair.of("TABLE_CAT", ""))), getRows(metaData.getCatalogs()));
}
Also used : DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 13 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project druid by druid-io.

the class DruidAvaticaHandlerTest method testDatabaseMetaDataSchemas.

@Test
public void testDatabaseMetaDataSchemas() throws Exception {
    final DatabaseMetaData metaData = client.getMetaData();
    Assert.assertEquals(ImmutableList.of(ROW(Pair.of("TABLE_CATALOG", ""), Pair.of("TABLE_SCHEM", "druid"))), getRows(metaData.getSchemas(null, "druid")));
}
Also used : DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 14 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project sharding-jdbc by dangdangdotcom.

the class MasterSlaveDataSourceTest method mockConnection.

private Connection mockConnection(final String dataBaseProductName) throws SQLException {
    Connection result = mock(Connection.class);
    DatabaseMetaData databaseMetaData = mock(DatabaseMetaData.class);
    when(result.getMetaData()).thenReturn(databaseMetaData);
    when(databaseMetaData.getDatabaseProductName()).thenReturn(dataBaseProductName);
    return result;
}
Also used : Connection(java.sql.Connection) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 15 with DatabaseMetaData

use of java.sql.DatabaseMetaData in project druid by druid-io.

the class PostgreSQLConnector method canUpsert.

protected boolean canUpsert(Handle handle) throws SQLException {
    if (canUpsert == null) {
        DatabaseMetaData metaData = handle.getConnection().getMetaData();
        canUpsert = metaData.getDatabaseMajorVersion() > 9 || (metaData.getDatabaseMajorVersion() == 9 && metaData.getDatabaseMinorVersion() >= 5);
    }
    return canUpsert;
}
Also used : DatabaseMetaData(java.sql.DatabaseMetaData)

Aggregations

DatabaseMetaData (java.sql.DatabaseMetaData)299 ResultSet (java.sql.ResultSet)176 Connection (java.sql.Connection)139 SQLException (java.sql.SQLException)116 Test (org.junit.Test)81 ResultSetMetaData (java.sql.ResultSetMetaData)41 Statement (java.sql.Statement)36 ArrayList (java.util.ArrayList)33 PreparedStatement (java.sql.PreparedStatement)29 Properties (java.util.Properties)24 PhoenixDatabaseMetaData (org.apache.phoenix.jdbc.PhoenixDatabaseMetaData)16 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)15 IOException (java.io.IOException)14 HashMap (java.util.HashMap)11 DataSource (javax.sql.DataSource)9 HashSet (java.util.HashSet)8 List (java.util.List)8 Savepoint (java.sql.Savepoint)6 GargoyleException (com.kyj.fx.voeditor.visual.exceptions.GargoyleException)5 TreeSet (java.util.TreeSet)5