Java Code Examples for java.sql.DatabaseMetaData#getPseudoColumns()

The following examples show how to use java.sql.DatabaseMetaData#getPseudoColumns() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetaResultSetTest.java    From calcite-avatica with Apache License 2.0 6 votes vote down vote up
@Test public void testGetPseudoColumns() throws SQLException {
  DatabaseMetaData metadata = getDatabaseMetadata();
  try (ResultSet rs = metadata.getPseudoColumns(null, null, null, null)) {
    ResultSetMetaData rsMeta = rs.getMetaData();

    assertEquals(12, rsMeta.getColumnCount());
    assertColumn(rsMeta, 1, "TABLE_CAT", Types.VARCHAR, DatabaseMetaData.columnNullable);
    assertColumn(rsMeta, 2, "TABLE_SCHEM", Types.VARCHAR, DatabaseMetaData.columnNullable);
    assertColumn(rsMeta, 3, "TABLE_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
    assertColumn(rsMeta, 4, "COLUMN_NAME", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
    assertColumn(rsMeta, 5, "DATA_TYPE", Types.INTEGER, DatabaseMetaData.columnNoNulls);
    assertColumn(rsMeta, 6, "COLUMN_SIZE", Types.INTEGER, DatabaseMetaData.columnNullable);
    assertColumn(rsMeta, 7, "DECIMAL_DIGITS", Types.INTEGER, DatabaseMetaData.columnNullable);
    assertColumn(rsMeta, 8, "NUM_PREC_RADIX", Types.INTEGER, DatabaseMetaData.columnNullable);
    assertColumn(rsMeta, 9, "COLUMN_USAGE", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
    assertColumn(rsMeta, 10, "REMARKS", Types.VARCHAR, DatabaseMetaData.columnNullable);
    assertColumn(rsMeta, 11, "CHAR_OCTET_LENGTH", Types.INTEGER, DatabaseMetaData.columnNullable);
    assertColumn(rsMeta, 12, "IS_NULLABLE", Types.VARCHAR, DatabaseMetaData.columnNoNulls);
  }
}
 
Example 2
Source File: Jdbc41Bridge.java    From Tomcat8-Source-Read with MIT License 3 votes vote down vote up
/**
 * Delegates to {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)} without throwing a
 * {@link AbstractMethodError}.
 * <p>
 * If the JDBC driver does not implement {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)},
 * then return null.
 * </p>
 *
 * @param databaseMetaData
 *            the receiver
 * @param catalog
 *            See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @param schemaPattern
 *            See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @param tableNamePattern
 *            See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @param columnNamePattern
 *            See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @return See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @throws SQLException
 *             See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @see DatabaseMetaData#getPseudoColumns(String, String, String, String)
 */
public static ResultSet getPseudoColumns(final DatabaseMetaData databaseMetaData, final String catalog,
        final String schemaPattern, final String tableNamePattern, final String columnNamePattern)
        throws SQLException {
    try {
        return databaseMetaData.getPseudoColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern);
    } catch (final AbstractMethodError e) {
        // do nothing
        return null;
    }
}
 
Example 3
Source File: Jdbc41Bridge.java    From commons-dbcp with Apache License 2.0 3 votes vote down vote up
/**
 * Delegates to {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)} without throwing a
 * {@link AbstractMethodError}.
 * <p>
 * If the JDBC driver does not implement {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)},
 * then return null.
 * </p>
 *
 * @param databaseMetaData
 *            the receiver
 * @param catalog
 *            See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @param schemaPattern
 *            See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @param tableNamePattern
 *            See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @param columnNamePattern
 *            See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @return See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @throws SQLException
 *             See {@link DatabaseMetaData#getPseudoColumns(String, String, String, String)}
 * @see DatabaseMetaData#getPseudoColumns(String, String, String, String)
 */
public static ResultSet getPseudoColumns(final DatabaseMetaData databaseMetaData, final String catalog,
        final String schemaPattern, final String tableNamePattern, final String columnNamePattern)
        throws SQLException {
    try {
        return databaseMetaData.getPseudoColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern);
    } catch (final AbstractMethodError e) {
        // do nothing
        return null;
    }
}