Exemplo n.º 1
0
/** GetIndexesRequest */
public class GetIndexesRequest extends MetadataRequest {

  public static final String NAME =
      JdbcPlugin.Util.getString("GetIndexesRequestName"); // $NON-NLS-1$
  private static final String METHOD_NAME = "getIndexInfo"; // $NON-NLS-1$

  /**
   * Construct an instance of GetIndexesRequest.
   *
   * @param metadata
   * @param catalogNamePattern
   * @param schemaNamePattern
   * @param tableNamePattern
   * @param uniqueValuesOnly
   * @param approximateAllowed
   */
  public GetIndexesRequest(
      final DatabaseMetaData metadata,
      final String catalogNamePattern,
      final String schemaNamePattern,
      final String tableNamePattern,
      final boolean uniqueValuesOnly,
      final boolean approximateAllowed) {
    super(
        NAME,
        metadata,
        METHOD_NAME,
        new Object[] {
          catalogNamePattern,
          schemaNamePattern,
          tableNamePattern,
          new Boolean(uniqueValuesOnly),
          new Boolean(approximateAllowed)
        });
  }

  /**
   * This method is overridden to optimize performance.
   *
   * @see
   *     com.metamatrix.modeler.jdbc.data.MethodRequest#performInvocation(com.metamatrix.modeler.jdbc.data.Response)
   * @since 4.2
   */
  @Override
  protected IStatus performInvocation(final Response results) {
    // Override to optimize ...
    final DatabaseMetaData dbmd = this.getDatabaseMetaData();
    ResultSet resultSet = null;
    IStatus status = null;
    try {
      final String catalogPattern = (String) getParameters()[0];
      final String schemaPattern = (String) getParameters()[1];
      final String tablePattern = (String) getParameters()[2];
      final boolean unique = ((Boolean) getParameters()[3]).booleanValue();
      final boolean approximate = ((Boolean) getParameters()[4]).booleanValue();
      resultSet =
          dbmd.getIndexInfo(catalogPattern, schemaPattern, tablePattern, unique, approximate);
      Response.addResults(results, resultSet, this.isMetadataRequested());
    } catch (SQLException e) {
      status = JdbcUtil.createIStatus(e, e.getLocalizedMessage());
    } finally {
      if (resultSet != null) {
        try {
          resultSet.close();
        } catch (SQLException e1) {
        }
      }
    }
    return status;
  }
}
Exemplo n.º 2
0
 /* (non-Javadoc)
  * @see com.metamatrix.modeler.jdbc.data.Request#performInvocation(com.metamatrix.modeler.jdbc.data.Response)
  */
 @Override
 protected IStatus performInvocation(final Response results) {
   final String msg =
       JdbcPlugin.Util.getString("DisabledRequest.RequestNotIncluded"); // $NON-NLS-1$
   return JdbcUtil.createIStatus(IStatus.INFO, msg);
 }