Search in sources :

Example 1 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getTypeInfo.

@Override
public ResultSet getTypeInfo() throws SQLException {
    String sql = CloudSpannerDatabaseMetaDataConstants.GET_TYPE_INFO;
    CloudSpannerPreparedStatement statement = prepareStatement(sql);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 2 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method prepareStatement.

private CloudSpannerPreparedStatement prepareStatement(String sql, String... params) throws SQLException {
    CloudSpannerPreparedStatement statement = connection.prepareStatement(sql);
    statement.setForceSingleUseReadContext(true);
    int paramIndex = 1;
    for (String param : params) {
        if (param != null) {
            statement.setString(paramIndex, param.toUpperCase());
            paramIndex++;
        }
    }
    return statement;
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 3 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getExportedKeys.

@Override
public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
    String sql = "SELECT " + "NULL AS PKTABLE_CAT, NULL AS PKTABLE_SCHEM, PARENT.TABLE_NAME AS PKTABLE_NAME, PARENT_INDEX_COLUMNS.COLUMN_NAME AS PKCOLUMN_NAME, " + "NULL AS FKTABLE_CAT, NULL AS FKTABLE_SCHEM, CHILD.TABLE_NAME AS FKTABLE_NAME, PARENT_INDEX_COLUMNS.COLUMN_NAME AS FKCOLUMN_NAME, " + "PARENT_INDEX_COLUMNS.ORDINAL_POSITION AS KEY_SEQ, 3 AS UPDATE_RULE, CASE WHEN CHILD.ON_DELETE_ACTION='CASCADE' THEN 0 ELSE 3 END AS DELETE_RULE, " + "NULL AS FK_NAME, 'PRIMARY_KEY' AS PK_NAME, 7 AS DEFERRABILITY " + "FROM INFORMATION_SCHEMA.TABLES PARENT " + "INNER JOIN INFORMATION_SCHEMA.TABLES CHILD ON CHILD.PARENT_TABLE_NAME=PARENT.TABLE_NAME " + "INNER JOIN INFORMATION_SCHEMA.INDEX_COLUMNS PARENT_INDEX_COLUMNS ON PARENT_INDEX_COLUMNS.TABLE_NAME=PARENT.TABLE_NAME AND PARENT_INDEX_COLUMNS.INDEX_NAME='PRIMARY_KEY' " + CloudSpannerDatabaseMetaDataConstants.WHERE_1_EQUALS_1;
    sql = sql + getCatalogSchemaTableWhereClause("PARENT", catalog, schema, table);
    sql = sql + "ORDER BY CHILD.TABLE_CATALOG, CHILD.TABLE_SCHEMA, CHILD.TABLE_NAME, PARENT_INDEX_COLUMNS.ORDINAL_POSITION ";
    CloudSpannerPreparedStatement statement = prepareStatement(sql, catalog, schema, table);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 4 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getUDTs.

@Override
public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException {
    String sql = CloudSpannerDatabaseMetaDataConstants.GET_UDTS;
    CloudSpannerPreparedStatement statement = prepareStatement(sql);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 5 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getSuperTables.

@Override
public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
    String sql = "SELECT '' AS TABLE_CAT, '' AS TABLE_SCHEM, '' AS TABLE_NAME, '' AS SUPERTABLE_NAME " + FROM_STATEMENT_WITHOUT_RESULTS;
    CloudSpannerPreparedStatement statement = prepareStatement(sql);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

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