Search in sources :

Example 11 with CloudSpannerPreparedStatement

use of nl.topicus.jdbc.statement.CloudSpannerPreparedStatement in project spanner-jdbc by olavloite.

the class CloudSpannerDatabaseMetaData method getColumns.

@Override
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
    String sql = CloudSpannerDatabaseMetaDataConstants.GET_COLUMNS;
    sql = sql + getCatalogSchemaTableWhereClause("C", catalog, schemaPattern, tableNamePattern);
    if (columnNamePattern != null)
        sql = sql + "AND UPPER(COLUMN_NAME) LIKE ? ";
    sql = sql + "ORDER BY TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION ";
    CloudSpannerPreparedStatement statement = prepareStatement(sql, catalog, schemaPattern, tableNamePattern, columnNamePattern);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 12 with CloudSpannerPreparedStatement

use of nl.topicus.jdbc.statement.CloudSpannerPreparedStatement in project spanner-jdbc by olavloite.

the class CloudSpannerDatabaseMetaData method getSuperTypes.

@Override
public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException {
    String sql = "SELECT '' AS TYPE_CAT, '' AS TYPE_SCHEM, '' AS TYPE_NAME, " + "'' AS SUPERTYPE_CAT, '' AS SUPERTYPE_SCHEM, '' AS SUPERTYPE_NAME " + FROM_STATEMENT_WITHOUT_RESULTS;
    CloudSpannerPreparedStatement statement = prepareStatement(sql);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 13 with CloudSpannerPreparedStatement

use of nl.topicus.jdbc.statement.CloudSpannerPreparedStatement in project spanner-jdbc by olavloite.

the class CloudSpannerDatabaseMetaData method getTables.

@Override
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
    String sql = CloudSpannerDatabaseMetaDataConstants.SELECT_TABLES_COLUMNS + CloudSpannerDatabaseMetaDataConstants.FROM_TABLES_T + CloudSpannerDatabaseMetaDataConstants.WHERE_1_EQUALS_1;
    sql = sql + getCatalogSchemaTableWhereClause("T", catalog, schemaPattern, tableNamePattern);
    sql = sql + "ORDER BY TABLE_NAME";
    CloudSpannerPreparedStatement statement = prepareStatement(sql, catalog, schemaPattern, tableNamePattern);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 14 with CloudSpannerPreparedStatement

use of nl.topicus.jdbc.statement.CloudSpannerPreparedStatement in project spanner-jdbc by olavloite.

the class CloudSpannerDatabaseMetaData method getAttributes.

@Override
public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException {
    String sql = "SELECT '' AS TYPE_CAT, '' AS TYPE_SCHEM, '' AS TYPE_NAME, '' AS ATTR_NAME, 0 AS DATA_TYPE, " + "'' AS ATTR_TYPE_NAME, 0 AS ATTR_SIZE, 0 AS DECIMAL_DIGITS, 0 AS NUM_PREC_RADIX, 0 AS NULLABLE, " + "'' AS REMARKS, '' AS ATTR_DEF, 0 AS SQL_DATA_TYPE, 0 AS SQL_DATETIME_SUB, 0 AS CHAR_OCTET_LENGTH, " + "0 AS ORDINAL_POSITION, 'NO' AS IS_NULLABLE, '' AS SCOPE_CATALOG, '' AS SCOPE_SCHEMA, '' AS SCOPE_TABLE, " + "0 AS SOURCE_DATA_TYPE " + FROM_STATEMENT_WITHOUT_RESULTS;
    CloudSpannerPreparedStatement statement = prepareStatement(sql);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 15 with CloudSpannerPreparedStatement

use of nl.topicus.jdbc.statement.CloudSpannerPreparedStatement in project spanner-jdbc by olavloite.

the class CloudSpannerTestObjects method mockXAMethods.

private static void mockXAMethods(CloudSpannerConnection connection) throws SQLException {
    String checkTable = null;
    try {
        Field field = CloudSpannerXAConnection.class.getDeclaredField("CHECK_TABLE_EXISTENCE");
        field.setAccessible(true);
        checkTable = (String) field.get(null);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    CloudSpannerPreparedStatement ps = Mockito.mock(CloudSpannerPreparedStatement.class);
    CloudSpannerResultSet rs = Mockito.mock(CloudSpannerResultSet.class);
    Mockito.when(rs.next()).thenReturn(true, false);
    Mockito.when(connection.prepareStatement(checkTable)).thenAnswer(new Returns(ps));
    Mockito.when(ps.executeQuery()).thenAnswer(new Returns(rs));
}
Also used : Field(java.lang.reflect.Field) Returns(org.mockito.internal.stubbing.answers.Returns) CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement) SQLException(java.sql.SQLException) CloudSpannerResultSet(nl.topicus.jdbc.resultset.CloudSpannerResultSet)

Aggregations

CloudSpannerPreparedStatement (nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)15 Field (java.lang.reflect.Field)1 SQLException (java.sql.SQLException)1 CloudSpannerResultSet (nl.topicus.jdbc.resultset.CloudSpannerResultSet)1 Returns (org.mockito.internal.stubbing.answers.Returns)1