Search in sources :

Example 1 with FBResultSet

use of org.firebirdsql.jdbc.FBResultSet in project jaybird by FirebirdSQL.

the class OODatabaseMetaData method getTablePrivileges.

@Override
public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
    final RowDescriptor rowDescriptor = buildTablePrivilegeRSMetaData();
    Clause tableClause1 = new Clause("RDB$RELATION_NAME", tableNamePattern);
    Clause tableClause2 = new Clause("RDB$RELATION_NAME", tableNamePattern);
    String sql = GET_TABLE_PRIVILEGES_START_1;
    sql += tableClause1.getCondition();
    sql += GET_TABLE_PRIVILEGES_END_1;
    sql += GET_TABLE_PRIVILEGES_START_2;
    sql += tableClause2.getCondition();
    sql += GET_TABLE_PRIVILEGES_END_2;
    List<String> params = new ArrayList<>(2);
    if (tableClause1.hasCondition()) {
        params.add(tableClause1.getValue());
    }
    if (tableClause2.hasCondition()) {
        params.add(tableClause2.getValue());
    }
    try (ResultSet rs = doQuery(sql, params)) {
        // if nothing found, return an empty result set
        if (!rs.next()) {
            return new FBResultSet(rowDescriptor, Collections.<RowValue>emptyList());
        }
        return processTablePrivileges(rowDescriptor, rs);
    }
}
Also used : ArrayList(java.util.ArrayList) FBResultSet(org.firebirdsql.jdbc.FBResultSet) ResultSet(java.sql.ResultSet) FBResultSet(org.firebirdsql.jdbc.FBResultSet) RowDescriptor(org.firebirdsql.gds.ng.fields.RowDescriptor)

Example 2 with FBResultSet

use of org.firebirdsql.jdbc.FBResultSet in project jaybird by FirebirdSQL.

the class OODatabaseMetaData method getColumns.

@Override
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
    if (DEFAULT_SCHEMA.equals(schemaPattern))
        schemaPattern = null;
    FBResultSet rs = (FBResultSet) super.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern);
    if (rs.next()) {
        rs.beforeFirst();
        return rs;
    }
    String upperTableNamePattern = tableNamePattern.toUpperCase();
    String upperColumnNamePattern = columnNamePattern.toUpperCase();
    rs = (FBResultSet) super.getColumns(catalog, schemaPattern, upperTableNamePattern, columnNamePattern);
    if (rs.next()) {
        rs.beforeFirst();
        return rs;
    }
    rs = (FBResultSet) super.getColumns(catalog, schemaPattern, tableNamePattern, upperColumnNamePattern);
    if (rs.next()) {
        rs.beforeFirst();
        return rs;
    }
    return super.getColumns(catalog, schemaPattern, upperTableNamePattern, upperColumnNamePattern);
}
Also used : FBResultSet(org.firebirdsql.jdbc.FBResultSet)

Example 3 with FBResultSet

use of org.firebirdsql.jdbc.FBResultSet in project jaybird by FirebirdSQL.

the class OODatabaseMetaData method getTables.

@Override
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
    if (DEFAULT_SCHEMA.equals(schemaPattern))
        schemaPattern = null;
    FBResultSet rs = (FBResultSet) super.getTables(catalog, schemaPattern, tableNamePattern, types);
    if (rs.next()) {
        rs.beforeFirst();
        return rs;
    }
    tableNamePattern = tableNamePattern.toUpperCase();
    return super.getTables(catalog, schemaPattern, tableNamePattern, types);
}
Also used : FBResultSet(org.firebirdsql.jdbc.FBResultSet)

Aggregations

FBResultSet (org.firebirdsql.jdbc.FBResultSet)3 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 RowDescriptor (org.firebirdsql.gds.ng.fields.RowDescriptor)1