Esempio n. 1
0
  private static void executeOS(
      String sourceType,
      String sourceServer,
      String sourceInstance,
      int sourcePort,
      String sourceDatabase,
      String sourceSchema,
      String sourceTable,
      String refreshType,
      String appendColumnName,
      int appendColumnMax,
      Connection gpConn,
      int queueId)
      throws Exception {
    String method = "executeOS";
    int location = 1000;

    String sourceUser = "";
    String sourcePass = "";
    String strSQL = "";
    int fetchSize = 10;
    Connection conn = null;

    try {
      location = 3000;

      ResultSet rs;
      Statement stmt;

      location = 3010;
      strSQL = GP.getQueueDetails(gpConn, queueId);

      location = 3020;
      stmt = gpConn.createStatement();

      location = 3040;
      rs = stmt.executeQuery(strSQL);

      while (rs.next()) {
        sourceUser = rs.getString(1);
        sourcePass = rs.getString(2);
      }

      location = 3090;
      if (sourceType.equals("sqlserver")) {
        location = 3100;
        conn = CommonDB.connectSQLServer(sourceServer, sourceInstance, sourceUser, sourcePass);

        location = 3200;
        // create SQL statement for selecting data
        strSQL =
            SQLServer.getSQLForData(
                conn,
                sourceDatabase,
                sourceSchema,
                sourceTable,
                refreshType,
                appendColumnName,
                appendColumnMax);

        location = 3300;
        // execute the SQL Statement
        CommonDB.outputData(conn, strSQL);

        location = 3400;
        conn.close();

      } else if (sourceType.equals("oracle")) {
        location = 4000;
        fetchSize = Integer.parseInt(GP.getVariable(gpConn, "oFetchSize"));

        location = 4100;
        conn =
            CommonDB.connectOracle(
                sourceServer, sourceDatabase, sourcePort, sourceUser, sourcePass, fetchSize);

        location = 4200;
        // execute the SQL Statement
        strSQL =
            Oracle.getSQLForData(
                conn, sourceSchema, sourceTable, refreshType, appendColumnName, appendColumnMax);

        location = 4300;
        // execute the SQL Statement
        CommonDB.outputData(conn, strSQL);

        location = 4400;
        conn.close();
      }

    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    } finally {
      if (conn != null) conn.close();
    }
  }
Esempio n. 2
0
  private static void executeExt(Connection gpConn, int connectionId, String selectSQL)
      throws Exception {
    String method = "executeExt";
    int location = 1000;

    String sourceType = "";
    String sourceServer = "";
    String sourceInstance = "";
    int sourcePort = 0;
    String sourceDatabase = "";
    String sourceUser = "";
    String sourcePass = "";
    String strSQL = "";
    Connection conn = null;
    int fetchSize = 10;

    try {
      location = 3000;

      ResultSet rs;
      Statement stmt;

      location = 3010;
      strSQL = GP.getExtConnectionDetails(gpConn, connectionId);

      location = 3020;
      stmt = gpConn.createStatement();

      location = 3030;
      rs = stmt.executeQuery(strSQL);

      while (rs.next()) {
        sourceType = rs.getString(1);
        sourceServer = rs.getString(2);
        sourceInstance = rs.getString(3);
        sourcePort = rs.getInt(4);
        sourceDatabase = rs.getString(5);
        sourceUser = rs.getString(6);
        sourcePass = rs.getString(7);
      }

      location = 3090;
      if (sourceType.equals("sqlserver")) {
        location = 3100;
        conn = CommonDB.connectSQLServer(sourceServer, sourceInstance, sourceUser, sourcePass);

        location = 3300;
        // execute the SQL Statement
        CommonDB.outputData(conn, selectSQL);

        location = 3400;
        conn.close();

      } else if (sourceType.equals("oracle")) {
        location = 4000;
        fetchSize = Integer.parseInt(GP.getVariable(gpConn, "oFetchSize"));

        location = 4100;
        conn =
            CommonDB.connectOracle(
                sourceServer, sourceDatabase, sourcePort, sourceUser, sourcePass, fetchSize);

        location = 4200;
        // execute the SQL Statement
        CommonDB.outputData(conn, selectSQL);

        location = 4400;
        conn.close();
      }

    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    } finally {
      if (conn != null) conn.close();
    }
  }