test_class.declarator: runSqlEntity = new RunSqlEntity()
test_class.original_string: RunSqlEntity runSqlEntity = new RunSqlEntity();
test_class.type: RunSqlEntity
test_class.var_name: runSqlEntity
test_class.declarator: properties = new Properties()
test_class.original_string: Properties properties = new Properties();
test_class.type: Properties
test_class.var_name: properties
test_class.file: hydrograph.engine/hydrograph.engine.spark/src/test/scala/hydrograph/engine/spark/components/RunSQLComponentTest.java
test_class.identifier: RunSQLComponentTest
test_case.body: @Test(expected = RuntimeException.class)
      public void throwException_IfDatabaseQueryIsInvalid() throws IOException {
          runSqlEntity.setBatch("0");
          runSqlEntity.setComponentId("1");
          runSqlEntity.setComponentName("RunSQLComponent");
          runSqlEntity.setDatabaseConnectionName("Oracle");
          runSqlEntity.setDatabaseName("PRACTICE");
          runSqlEntity.setDbPwd("Bitwise2017");
          runSqlEntity.setPortNumber("1521");
          runSqlEntity.setQueryCommand("insert into testPassssssss(1,1,1,1)");
          runSqlEntity.setDbUserName("htcd");
          runSqlEntity.setServerName("DBDEVSRV");
          RunSQLComponent runSQLComponent = new RunSQLComponent(runSqlEntity);
          runSQLComponent.execute();
  
      }
test_case.class_method_signature: RunSQLComponentTest.throwException_IfDatabaseQueryIsInvalid()
test_case.full_signature: @Test(expected = RuntimeException.class) public void throwException_IfDatabaseQueryIsInvalid()
test_case.identifier: throwException_IfDatabaseQueryIsInvalid
test_case.invocations: setBatch setComponentId setComponentName setDatabaseConnectionName setDatabaseName setDbPwd setPortNumber setQueryCommand setDbUserName setServerName execute
test_case.modifiers: @Test(expected = RuntimeException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void throwException_IfDatabaseQueryIsInvalid()
focal_class.declarator: log = Logger.getLogger(RunSQLComponent.class.getName())
focal_class.modifier: static final
focal_class.original_string: static final Logger log = Logger.getLogger(RunSQLComponent.class.getName());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: tempFile = File.createTempFile("query", ".txt", new File("."))
focal_class.original_string: File tempFile = File.createTempFile("query", ".txt", new File("."));
focal_class.type: File
focal_class.var_name: tempFile
focal_class.declarator: assemblyEntityBase
focal_class.modifier: private
focal_class.original_string: private AssemblyEntityBase assemblyEntityBase;
focal_class.type: AssemblyEntityBase
focal_class.var_name: assemblyEntityBase
focal_class.declarator: runSqlEntity
focal_class.modifier: private
focal_class.original_string: private RunSqlEntity runSqlEntity;
focal_class.type: RunSqlEntity
focal_class.var_name: runSqlEntity
focal_class.file: hydrograph.engine/hydrograph.engine.spark/src/main/scala/hydrograph/engine/spark/components/RunSQLComponent.java
focal_class.identifier: RunSQLComponent
focal_class.interfaces: implements Serializable
focal_class.class_method_signature: RunSQLComponent.RunSQLComponent(AssemblyEntityBase assemblyEntityBase)
focal_class.full_signature: public  RunSQLComponent(AssemblyEntityBase assemblyEntityBase)
focal_class.identifier: RunSQLComponent
focal_class.modifiers: public
focal_class.parameters: (AssemblyEntityBase assemblyEntityBase)
focal_class.signature:  RunSQLComponent(AssemblyEntityBase assemblyEntityBase)
focal_class.class_method_signature: RunSQLComponent.execute()
focal_class.full_signature: @Override public void execute()
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void execute()
focal_class.class_method_signature: RunSQLComponent.scriptBuilder(String statement)
focal_class.full_signature: private void scriptBuilder(String statement)
focal_class.identifier: scriptBuilder
focal_class.modifiers: private
focal_class.parameters: (String statement)
focal_class.return: void
focal_class.signature: void scriptBuilder(String statement)
focal_class.superclass: extends CommandComponentSparkFlow
focal_method.body: @Override
      public void execute() {
          Properties properties = new Properties();
          Connection conn = null;
          Reader reader = null;
  
          if (((null != runSqlEntity.getDatabaseConnectionName()) && !(runSqlEntity.getDatabaseConnectionName().trim().isEmpty()))
                  && ((null != runSqlEntity.getQueryCommand()) && !(runSqlEntity.getQueryCommand().trim().isEmpty()))) {
              if (runSqlEntity.getDatabaseConnectionName().equalsIgnoreCase("MYSQL")) {
                  log.debug("Request received test connection " + runSqlEntity.getDatabaseConnectionName());
                  try {
                      properties.setProperty("className", "com.mysql.jdbc.Driver");
                      conn = DriverManager.getConnection("jdbc:mysql://" + runSqlEntity.getServerName() + ":" + runSqlEntity.getPortNumber() + "/" + runSqlEntity.getDatabaseName() + "?allowMultiQueries=true", runSqlEntity.getDbUserName(), runSqlEntity.getDbPwd());
                      conn.setAutoCommit(false);
                      scriptBuilder(runSqlEntity.getQueryCommand());
                      ScriptRunner sr = new ScriptRunner(conn, false, true);
                      reader = new BufferedReader(new FileReader(tempFile));
                      sr.runScript(reader);
                  } catch (SQLException | IOException | ClassNotFoundException e) {
                      log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                      throw new RuntimeException(e);
                  } finally {
                      Exception ex = null;
                      try {
                          SafeResourceClose.safeReaderClose(reader);
                      } catch (IOException e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
                      try {
                          tempFile.deleteOnExit();
                      } catch (Exception e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
                      try {
                          SafeResourceClose.safeConnectionClose(conn);
                      } catch (SQLException e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
  
                      if(ex != null) {
                          throw new RuntimeException(ex);
                      }
                  }
              } else if (runSqlEntity.getDatabaseConnectionName().equalsIgnoreCase("Oracle")) {
                  log.debug("Request received test connection " + runSqlEntity.getDatabaseConnectionName());
                  try {
                      properties.setProperty("className", "oracle.jdbc.driver.OracleDriver");
                      conn = DriverManager.getConnection("jdbc:oracle:thin://@" + runSqlEntity.getServerName() + ":" + runSqlEntity.getPortNumber() + "/" + runSqlEntity.getDatabaseName(), runSqlEntity.getDbUserName(), runSqlEntity.getDbPwd());
                      conn.setAutoCommit(false);
                      scriptBuilder(runSqlEntity.getQueryCommand());
                      ScriptRunner sr = new ScriptRunner(conn, false, true);
                      reader = new BufferedReader(new FileReader(tempFile));
                      sr.runScript(reader);
                  } catch (SQLException | IOException | ClassNotFoundException e) {
                      log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                      throw new RuntimeException(e);
                  } finally {
                      Exception ex = null;
                      try {
                          SafeResourceClose.safeReaderClose(reader);
                      } catch (IOException e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
                      try {
                          tempFile.deleteOnExit();
                      } catch (Exception e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
                      try {
                          SafeResourceClose.safeConnectionClose(conn);
                      } catch (SQLException e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
  
                      if(ex != null) {
                          throw new RuntimeException(ex);
                      }
                  }
              } else if (runSqlEntity.getDatabaseConnectionName().equalsIgnoreCase("Teradata")) {
                  log.debug("Request received test connection " + runSqlEntity.getDatabaseConnectionName());
                  try {
                      properties.setProperty("className", "com.teradata.jdbc.TeraDriver");
                      conn = DriverManager.getConnection("jdbc:teradata://" + runSqlEntity.getServerName() + "/DATABASE=" + runSqlEntity.getDatabaseName() + ",USER=" + runSqlEntity.getDbUserName() + ", " + Constants.TERADATA_PWD + "=" + runSqlEntity.getDbPwd() + ",TMODE=ANSI,CHARSET=UTF8");
                      conn.setAutoCommit(false);
                      scriptBuilder(runSqlEntity.getQueryCommand());
                      ScriptRunner sr = new ScriptRunner(conn, false, true);
                      reader = new BufferedReader(new FileReader(tempFile));
                      sr.runScript(reader);
                  } catch (SQLException | IOException | ClassNotFoundException e) {
                      log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                      throw new RuntimeException(e);
                  } finally {
                      Exception ex = null;
                      try {
                          SafeResourceClose.safeReaderClose(reader);
                      } catch (IOException e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
                      try {
                          tempFile.deleteOnExit();
                      } catch (Exception e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
                      try {
                          SafeResourceClose.safeConnectionClose(conn);
                      } catch (SQLException e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                          ex = e;
                      }
  
                      if(ex != null) {
                          throw new RuntimeException(ex);
                      }
                  }
              } else if (runSqlEntity.getDatabaseConnectionName().equalsIgnoreCase("Redshift")) {
                  log.debug("Request received test connection " + runSqlEntity.getDatabaseConnectionName());
                  try {
                      properties.setProperty("className", "com.amazon.redshift.jdbc42.Driver");
                      conn = DriverManager.getConnection("jdbc:redshift://" + runSqlEntity.getServerName() + ":" + runSqlEntity.getPortNumber() + "/" + runSqlEntity.getDatabaseName(), runSqlEntity.getDbUserName(), runSqlEntity.getDbPwd());
                      conn.setAutoCommit(false);
                      scriptBuilder(runSqlEntity.getQueryCommand());
                      ScriptRunner sr = new ScriptRunner(conn, false, true);
                      reader = new BufferedReader(new FileReader(tempFile));
                      sr.runScript(reader);
                  } catch (SQLException | IOException | ClassNotFoundException e) {
                      log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                      throw new RuntimeException(e);
                  } finally {
                      try {
                          SafeResourceClose.safeReaderClose(reader);
                      } catch (IOException e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                      }
                      try {
                          tempFile.deleteOnExit();
                      } catch (Exception e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                      }
                      try {
                          SafeResourceClose.safeConnectionClose(conn);
                      } catch (SQLException e) {
                          log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + " The error is " + e.getMessage());
                      }
                  }
              }
          } else {
              log.debug("Failed to Execute" + runSqlEntity.getQueryCommand() + "Required field is empty.");
              throw new DatabaseConnectionException("Required field is empty.",null);
          }
      }
focal_method.class_method_signature: RunSQLComponent.execute()
focal_method.full_signature: @Override public void execute()
focal_method.identifier: execute
focal_method.invocations: getDatabaseConnectionName isEmpty trim getDatabaseConnectionName getQueryCommand isEmpty trim getQueryCommand equalsIgnoreCase getDatabaseConnectionName debug getDatabaseConnectionName setProperty getConnection getServerName getPortNumber getDatabaseName getDbUserName getDbPwd setAutoCommit scriptBuilder getQueryCommand runScript debug getQueryCommand getMessage safeReaderClose debug getQueryCommand getMessage deleteOnExit debug getQueryCommand getMessage safeConnectionClose debug getQueryCommand getMessage equalsIgnoreCase getDatabaseConnectionName debug getDatabaseConnectionName setProperty getConnection getServerName getPortNumber getDatabaseName getDbUserName getDbPwd setAutoCommit scriptBuilder getQueryCommand runScript debug getQueryCommand getMessage safeReaderClose debug getQueryCommand getMessage deleteOnExit debug getQueryCommand getMessage safeConnectionClose debug getQueryCommand getMessage equalsIgnoreCase getDatabaseConnectionName debug getDatabaseConnectionName setProperty getConnection getServerName getDatabaseName getDbUserName getDbPwd setAutoCommit scriptBuilder getQueryCommand runScript debug getQueryCommand getMessage safeReaderClose debug getQueryCommand getMessage deleteOnExit debug getQueryCommand getMessage safeConnectionClose debug getQueryCommand getMessage equalsIgnoreCase getDatabaseConnectionName debug getDatabaseConnectionName setProperty getConnection getServerName getPortNumber getDatabaseName getDbUserName getDbPwd setAutoCommit scriptBuilder getQueryCommand runScript debug getQueryCommand getMessage safeReaderClose debug getQueryCommand getMessage deleteOnExit debug getQueryCommand getMessage safeConnectionClose debug getQueryCommand getMessage debug getQueryCommand
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void execute()