Package org.apache.sqoop.common

Examples of org.apache.sqoop.common.SqoopException


        try {
          DriverManager.getConnection(shutDownUrl);
        } catch (SQLException ex) {
          // Shutdown for one db instance is expected to raise SQL STATE 45000
          if (ex.getErrorCode() != 45000) {
            throw new SqoopException(
                DerbyRepoError.DERBYREPO_0002, shutDownUrl, ex);
          }
          LOG.info("Embedded Derby shutdown raised SQL STATE "
              + "45000 as expected.");
        }
View Full Code Here


      if(foundAll && !tableNames.contains(DerbySchemaConstants.TABLE_SQ_SYSTEM_NAME)) {
        return 1;
      }

    } catch (SQLException e) {
      throw new SqoopException(DerbyRepoError.DERBYREPO_0041, e);
    } finally {
      closeResultSets(rs);
    }

    // Normal version detection, select and return the version
View Full Code Here

      stmt.setString(1, DerbyRepoConstants.SYSKEY_FRAMEWORK_VERSION);
      stmt.setString(2, mFramework.getVersion());
      stmt.executeUpdate();
    } catch (SQLException e) {
      logException(e);
      throw new SqoopException(DerbyRepoError.DERBYREPO_0044, e);
    } finally {
      closeResultSets(rs);
      closeStatements(stmt);
    }
  }
View Full Code Here

        new MConnectionForms(connectionForms),
        convertToJobList(jobForms));
      mc.setPersistenceId(connectorId);

      if (rsetBaseConnector.next()) {
        throw new SqoopException(DerbyRepoError.DERBYREPO_0005, shortName);
      }
    } catch (SQLException ex) {
      logException(ex, shortName);
      throw new SqoopException(DerbyRepoError.DERBYREPO_0004, shortName, ex);
    } finally {
      closeStatements(baseConnectorFetchStmt,
        formFetchStmt, inputFetchStmt);
    }
View Full Code Here

              subContext = new PrefixContext(conf, "");
              configConnection = ConfigurationUtils.getConfigFrameworkConnection(conf);
              configJob = ConfigurationUtils.getConfigFrameworkJob(conf);
              break;
            default:
              throw new SqoopException(MapreduceExecutionError.MAPRED_EXEC_0023);
          }
        }

        // Create loader context
        LoaderContext loaderContext = new LoaderContext(subContext, reader, schema);

        LOG.info("Running loader class " + loaderName);
        loader.load(loaderContext, configConnection, configJob);
        LOG.info("Loader has finished");
      } catch (Throwable t) {
        readerFinished = true;
        LOG.error("Error while loading data out of MR job.", t);
        // Release so that the writer can tell the framework something went
        // wrong.
        free.release();
        throw new SqoopException(MapreduceExecutionError.MAPRED_EXEC_0018, t);
      }

      // if no exception happens yet and reader finished before writer,
      // something went wrong
      if (!writerFinished) {
        // throw exception if data are not all consumed
        readerFinished = true;
        LOG.error("Reader terminated, but writer is still running!");
        // Release so that the writer can tell the framework something went
        // wrong.
        free.release();
        throw new SqoopException(MapreduceExecutionError.MAPRED_EXEC_0019);

      }
      // inform writer that reader is finished
      readerFinished = true;
    }
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public void registerFramework(MFramework mf, Connection conn) {
    if (mf.hasPersistenceId()) {
      throw new SqoopException(DerbyRepoError.DERBYREPO_0011,
        "Framework metadata");
    }

    PreparedStatement baseFormStmt = null;
    PreparedStatement baseInputStmt = null;
    try {
      baseFormStmt = conn.prepareStatement(STMT_INSERT_FORM_BASE,
          Statement.RETURN_GENERATED_KEYS);
      baseInputStmt = conn.prepareStatement(STMT_INSERT_INPUT_BASE,
          Statement.RETURN_GENERATED_KEYS);

      // Register connector forms
      registerForms(null, null, mf.getConnectionForms().getForms(),
        MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);

      // Register all jobs
      for (MJobForms jobForms : mf.getAllJobsForms().values()) {
        registerForms(null, jobForms.getType(), jobForms.getForms(),
          MFormType.JOB.name(), baseFormStmt, baseInputStmt);
      }

      // We're using hardcoded value for framework metadata as they are
      // represented as NULL in the database.
      mf.setPersistenceId(1);
    } catch (SQLException ex) {
      logException(ex, mf);
      throw new SqoopException(DerbyRepoError.DERBYREPO_0014, ex);
    } finally {
      closeStatements(baseFormStmt, baseInputStmt);
    }
    createOrUpdateFrameworkVersion(conn, mf);
  }
View Full Code Here

      // We're using hardcoded value for framework metadata as they are
      // represented as NULL in the database.
      mf.setPersistenceId(1);

    } catch (SQLException ex) {
      throw new SqoopException(DerbyRepoError.DERBYREPO_0004,
        "Framework metadata", ex);
    } finally {
      if (formFetchStmt != null) {
        try {
          formFetchStmt.close();
View Full Code Here

      stmt.setString(6, connection.getLastUpdateUser());
      stmt.setTimestamp(7, new Timestamp(connection.getLastUpdateDate().getTime()));

      result = stmt.executeUpdate();
      if (result != 1) {
        throw new SqoopException(DerbyRepoError.DERBYREPO_0012,
          Integer.toString(result));
      }

      ResultSet rsetConnectionId = stmt.getGeneratedKeys();

      if (!rsetConnectionId.next()) {
        throw new SqoopException(DerbyRepoError.DERBYREPO_0013);
      }

      long connectionId = rsetConnectionId.getLong(1);

      createInputValues(STMT_INSERT_CONNECTION_INPUT,
        connectionId,
        connection.getConnectorPart().getForms(),
        conn);
      createInputValues(STMT_INSERT_CONNECTION_INPUT,
        connectionId,
        connection.getFrameworkPart().getForms(),
        conn);

      connection.setPersistenceId(connectionId);

    } catch (SQLException ex) {
      logException(ex, connection);
      throw new SqoopException(DerbyRepoError.DERBYREPO_0019, ex);
    } finally {
      closeStatements(stmt);
    }
  }
View Full Code Here

        connection.getFrameworkPart().getForms(),
        conn);

    } catch (SQLException ex) {
      logException(ex, connection);
      throw new SqoopException(DerbyRepoError.DERBYREPO_0021, ex);
    } finally {
      closeStatements(deleteStmt, updateStmt);
    }
  }
View Full Code Here

      rs.next();

      return rs.getLong(1) == 1;
    } catch (SQLException ex) {
      logException(ex, id);
      throw new SqoopException(DerbyRepoError.DERBYREPO_0025, ex);
    } finally {
      closeResultSets(rs);
      closeStatements(stmt);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.sqoop.common.SqoopException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.