Search in sources :

Example 6 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getTablePrivileges.

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

Example 7 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getPseudoColumns.

@Override
public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
    String sql = "select TABLE_CATALOG AS TABLE_CAT, TABLE_SCHEMA AS TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, " + "CASE " + "	WHEN SPANNER_TYPE = 'ARRAY' THEN " + Types.ARRAY + " " + "	WHEN SPANNER_TYPE = 'BOOL' THEN " + Types.BOOLEAN + " " + "	WHEN SPANNER_TYPE = 'BYTES' THEN " + Types.BINARY + " " + "	WHEN SPANNER_TYPE = 'DATE' THEN " + Types.DATE + " " + "	WHEN SPANNER_TYPE = 'FLOAT64' THEN " + Types.DOUBLE + " " + "	WHEN SPANNER_TYPE = 'INT64' THEN " + Types.BIGINT + " " + "	WHEN SPANNER_TYPE = 'STRING' THEN " + Types.NVARCHAR + " " + "	WHEN SPANNER_TYPE = 'STRUCT' THEN " + Types.STRUCT + " " + "	WHEN SPANNER_TYPE = 'TIMESTAMP' THEN " + Types.TIMESTAMP + " " + "END AS DATA_TYPE, " + "0 AS COLUMN_SIZE, NULL AS DECIMAL_DIGITS, 0 AS NUM_PREC_RADIX, 'USAGE_UNKNOWN' AS COLUMN_USAGE, NULL AS REMARKS, 0 AS CHAR_OCTET_LENGTH, IS_NULLABLE " + FROM_STATEMENT_WITHOUT_RESULTS;
    sql = sql + getCatalogSchemaTableWhereClause("T", 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 8 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getVersionColumnsOrBestRowIdentifier.

/**
 * A simple private method that combines the result of two methods that
 * return exactly the same result
 *
 * @return An empty {@link ResultSet} containing the columns for the methods
 *         {@link DatabaseMetaData#getBestRowIdentifier(String, String, String, int, boolean)}
 *         and
 *         {@link DatabaseMetaData#getVersionColumns(String, String, String)}
 * @throws SQLException
 */
private ResultSet getVersionColumnsOrBestRowIdentifier() throws SQLException {
    String sql = VERSION_AND_IDENTIFIER_COLUMNS_SELECT_STATEMENT + FROM_STATEMENT_WITHOUT_RESULTS;
    CloudSpannerPreparedStatement statement = prepareStatement(sql);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 9 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getCatalogs.

@Override
public ResultSet getCatalogs() throws SQLException {
    String sql = "SELECT '' AS TABLE_CAT " + FROM_STATEMENT_WITHOUT_RESULTS;
    CloudSpannerPreparedStatement statement = prepareStatement(sql);
    return statement.executeQuery();
}
Also used : CloudSpannerPreparedStatement(nl.topicus.jdbc.statement.CloudSpannerPreparedStatement)

Example 10 with CloudSpannerPreparedStatement

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

the class CloudSpannerDatabaseMetaData method getColumnPrivileges.

@Override
public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException {
    String sql = "SELECT '' AS TABLE_CAT, '' AS TABLE_SCHEM, '' AS TABLE_NAME, '' AS COLUMN_NAME, '' AS GRANTOR, '' AS GRANTEE, '' AS PRIVILEGE, 'NO' AS IS_GRANTABLE " + 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